We help IT Professionals succeed at work.

Send email through Exchange Server programmatically (C++, SDK, no MFC, no .NET)


I need to send email messages using an Exchange Server. I am programming in C/C++ (MSVC .NET 2003) and I am not using (nor do I intend to use) MFC or ASP.
How should I proceed?
Is there an SDK for that purpose anywhere? I've been looking around, no results yet.

Thank you,

Watch Question

.net already has SmtpMail class...but use it only for framework 1.1. For higher version of framework use SmtpClient class

see the code below
#using <mscorlib.dll>
#using <System.dll>
#using <System.Web.dll>
using namespace System;
using namespace System::Web::Mail;
void DisplayUsage() 
   Console::WriteLine(S"Usage SendMail.exe <to> <from> <subject> <body>");
   Console::WriteLine(S"<to> the addresses of the email recipients");
   Console::WriteLine(S"<from> your email address");
   Console::WriteLine(S"<subject> subject of your email");
   Console::WriteLine(S"<body> the text of the email");
   Console::WriteLine(S"SendMail.exe SomeOne@Contoso.com;SomeOther@Contoso.com Me@contoso.com Hi hello");
int main() 
   String* args[] = Environment::GetCommandLineArgs();
         MailMessage* Message = new MailMessage();
         Message->To = args[1];
         Message->From = args[2];
         Message->Subject = args[3];
         Message->Body = args[4];
            SmtpMail::SmtpServer = S"your mail server name goes here";
         catch (System::Web::HttpException* ehttp) 
            Console::WriteLine(S" {0}", ehttp->Message);
            Console::WriteLine(S"Here is the full error message output");
            Console::Write(S" {0}", ehttp);
      catch (IndexOutOfRangeException*) 
   catch (System::Exception* e) 
      Console::WriteLine(S"Unknown Exception occurred {0}", e->Message);
      Console::WriteLine(S"Here is the Full Message output");
      Console::WriteLine(S" {0}", e);

Open in new window

if you intend to use higher version of .net , see my post (its second post) on



Like I said, I am not planning to use .NET. I need this application to be as self-contained as possible.
Still looking...
there is no implementation of API or library for SMTP nto windows by default. You will either have to use .net or some other library, unless you plan to write the code for SMTP protocol yourself.

If you need to only send mail through exchange server, you can use MAPI (Messaging API). But this will restrict your application to exchange server only.

MAPI is installed on a system when you install Microsoft Office.


Thank you. Actually, I could do it using SMTP only, and I needed this as an alternative when the users only have Exchange Server and no SMTP server.

Explore More ContentExplore courses, solutions, and other research materials related to this topic.