Sending mail through exchange server using SMTPClient not saving email in the sent items folder.

hi, I'm sending emails through exchange server 2007 using below code. It sends the email successfully but does not save a copy of the email into the [Sent Items] folder:

System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient("mydomainserver");
           client.Credentials = new System.Net.NetworkCredential("userid", "password", "domain");
           System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();
           mail.From = new System.Net.Mail.MailAddress("abc@mydomain.com");
           mail.To.Add("abc@xyz.com");
           mail.Subject = "test subject";
           mail.IsBodyHtml = true;
           mail.Body = "test body";

           client.Send(mail);

Can anyone please let me know what I should do to store a copy of each email sent using this code into [Sent Items] folder?

Thanks in advance...

-Jahedur Rahman


July 12th, 2013 6:24am

Hi,

FYI

There is a separate MSExchange Api called

Exchange Web Services

Solution

Your solution uses smtp directly and hence

may not work

Also see if these

settings help

Re

Free Windows Admin Tool Kit Click here and download it now
July 12th, 2013 6:34am

Saving to sent items is controlled by Outlook not Exchange, hence within Outlook you'll find there's an option (selected by default) for "Save copies of message in the Sent Items folder".

To get a message saved to sent items you'd need to call Outlook to send the message rather than SMTPClient. There's examples of how to do so http://stackoverflow.com/questions/6122515/how-to-save-mail-in-sent-items-in-ms-outlook-using-vb-net and http://social.msdn.microsoft.com/Forums/vstudio/en-US/97b21432-77e7-4693-aed6-2cc861703594/create-outlook-message-from-vbnet which should help. Of course it does require the machine sending the message to have Outlook installed on it which depending on where you're sending it from may or may not be an issue for you.

July 12th, 2013 6:36am

Keith,

I'm not using Outlook object model, and was planning to use SMTP client to send emails. So the solution above to use EWS Api helped me doing what I needed.

Thanks for your response!

Free Windows Admin Tool Kit Click here and download it now
July 17th, 2013 11:59pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics