Email using CDO Exchange c#
While working on a Report Automation project where the reports were generated at end of each day and emailed out to the business group, there was no way to test out the email content as the SMTP server were located behind an internal firewall and there was no way to access the SMTP server from my development machine. Following was the error message being thrown out:
OpenSmtp.Mail.SmtpException: ERROR - Expecting: 250. Recieved: 553 sorry, that
domain isn't in my list of allowed rcpthosts (#5.7.1)
at OpenSmtp.Mail.Smtp.CheckForError(String s, String successCode)
at OpenSmtp.Mail.Smtp.SendRecipientList(NetworkStream& nwstream, ArrayList recipients)
at OpenSmtp.Mail.Smtp.SendMail(MailMessage msg)
at Program.Sendmail(String pTo, String pSubject, String pBody)
So while looking around for alternate methods, I came across CDO [Collaboration Data Objects]. With CDO you can access Exchange services from code and also access information from Exchange such as Emails, calendars, contacts etc. CDO is basically a COM based interface for accessing Exchange. Obviously MSDN has vast amount of information about CDO and it's interfaces [http://msdn.microsoft.com/en-us/magazine/cc301434.aspx]. For quick implementation of CDO for sending emails you can use the following code:
<< Home