[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1717
  • Last Modified:

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

Hello,

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,

Daniel
0
daniblum
Asked:
daniblum
  • 4
  • 2
2 Solutions
 
ashutosh_kumarCommented:
.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"Example:");
   Console::WriteLine(S"SendMail.exe SomeOne@Contoso.com;SomeOther@Contoso.com Me@contoso.com Hi hello");
}
 
int main() 
{
   String* args[] = Environment::GetCommandLineArgs();
   try 
   {
      try 
      {
         MailMessage* Message = new MailMessage();
         Message->To = args[1];
         Message->From = args[2];
         Message->Subject = args[3];
         Message->Body = args[4];
 
         try 
         {
            SmtpMail::SmtpServer = S"your mail server name goes here";
            SmtpMail::Send(Message);
         } 
         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*) 
      {
         DisplayUsage();
      }
   } 
   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

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

http://www.experts-exchange.com/Microsoft/Development/.NET/Visual_CSharp/Q_23113345.html
0
 
daniblumAuthor Commented:
Like I said, I am not planning to use .NET. I need this application to be as self-contained as possible.
Still looking...
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
ashutosh_kumarCommented:
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.

0
 
ashutosh_kumarCommented:
MAPI is installed on a system when you install Microsoft Office.
0
 
daniblumAuthor Commented:
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.
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now