Bao Doan
Bao Doan

Reputation: 126

Send a mail through exchange server with C++ , EWS

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

Upvotes: 3

Views: 3141

Answers (1)

Bao Doan
Bao Doan

Reputation: 126

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

Upvotes: 1

Related Questions