using outlook object model to add a MailItem to the Sent Items folder

O

Omatase

I want to add a MailItem directly to the Sent Items folder. I don't
want to actually 'send' the email. The purpose of adding the email to
the Sent Items folder is just to show that it was actually sent at
some point. The email was in fact already sent by another application
previously.

Here is the code I have tried to use, the problem I am having is that
the MailItem will only make it to the Drafts folder.

Microsoft.Office.Interop.Outlook.MAPIFolder outBoxfolder =
_MAPINamespace.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderSentMail);

Microsoft.Office.Interop.Outlook.MailItem mailItem =
(Microsoft.Office.Interop.Outlook.MailItem)outBoxfolder.Items.Add(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);

mailItem.Body = "test";
mailItem.To = "[email protected]";
mailItem.Subject = "subject";

mailItem.Save();

mailItem.Close(OlInspectorClose.olSave);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top