本文介绍了通过C ++,EWS的交换服务器发送邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 使用系统; 
using System.Collections.Generic;
using System.Text;
使用System.Net;
使用System.Net.Mail;
using Microsoft.Exchange.WebServices.Data;


命名空间电子邮件
{


类程序
{
static void Main(string [] args )
{
try
{
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP1);

service.UseDefaultCredentials = false;
service.Credentials = new NetworkCredential(id_in_server,Password_in_server);
service.Url = new Uri(https://myexchangeserver/EWS/exchange.asmx);
Console.WriteLine(service.Url);

service.TraceEnabled = true;
EmailMessage message = new EmailMessage(service);
message.Subject =Hello from the EWS Managed API;
message.Body =Good Job!
message.ToRecipients.Add(recipient_mail_address);

//message.Save();
message.SendAndSaveCopy();
} catch(Exception e)
{
Console.WriteLine(e.ToString());
}

}
}

}

我发送邮件使用EWS,C#没有outlook和它工作确定。但在C + +,我不能,如果使用MAPI库1配置文件外观需要。我看到一个例子在C ++中使用Webservice 但我不能使用这个。现在,我想通过Exchange服务器使用C ++而不使用Outlook发送邮件。请帮帮我。感谢

解决方案

我解决了这个问题。
这是回答
我使用WWSAPI连接到C ++交换服务器。 / p>

using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.Net.Mail;
using Microsoft.Exchange.WebServices.Data;


namespace Email
{


    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP1);

                service.UseDefaultCredentials = false;
                service.Credentials = new NetworkCredential("id_in_server",   "Password_in_server");
                service.Url = new Uri("https://myexchangeserver/EWS/exchange.asmx");
                Console.WriteLine(service.Url);

                service.TraceEnabled = true; 
                EmailMessage message = new EmailMessage(service);
                message.Subject = "Hello from the EWS Managed API";
                message.Body = "Good Job!";
                message.ToRecipients.Add("recipient_mail_address");

                //message.Save();
                message.SendAndSaveCopy();  
            }catch(Exception e)
            {
                Console.WriteLine(e.ToString());
            }

        }
    }

}

I sent mail use EWS , C# without outlook and it worked ok.But in C++ , I can't, if use MAPI library 1 profile outlook required. I see a example use Webservice in C++ http://social.msdn.microsoft.com/Forums/en-US/wwsapi/thread/adf2a58c-32b7-477a-adcc-f2d053e2902b but I can't use this. Now, I want to send mail through exchange server use C++ without Outlook. Please help me. Thanks

解决方案

I solved this problem.Here is answer http://social.msdn.microsoft.com/Forums/en-US/wwsapi/thread/f0800af0-e62f-4b62-96e6-c504923ab77aI used WWSAPI connect to exchange server with C++.

这篇关于通过C ++,EWS的交换服务器发送邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-16 11:10