Reputation: 323
So I have been generating emails through a C# application for the company I work for. Emails are generated fine. The only little issue is that when they are sent from the drafts folder, they are not moved to the sent folder. They stay in the drafts folder.
I didnt know if it was a setting on the email or not
Here is the code I used:
Outlook.Application objOutlook= new Outlook.Application();
// Creating a new Outlook Message from the Outlook Application Instance
// Assigns the "TO", "CC" and "BCC" Fields
// Assigns the Subject Field
Outlook._NameSpace oNameSpace = objOutlook.GetNamespace("MAPI");
Outlook.MAPIFolder folder = oNameSpace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderDrafts);
String body;
Outlook.MailItem mic = (Outlook.MailItem)(objOutlook.CreateItem(Outlook.OlItemType.olMailItem));
mic.To = receiver;
//Code that fills in body and what not of the email
mic.Subject = subject;
mic.HTMLBody = body;
mic.SaveSentMessageFolder = folder
mic.Save();
Maybe some one has a idea? Thanks for the help!
Upvotes: 1
Views: 1524
Reputation: 64118
I believe it is saving the emails in the Drafts folder after being sent because you asked it to save it there.
Outlook.MAPIFolder folder
= oNameSpace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderDrafts);
...
mic.SaveSentMessageFolder = folder
...a MAPIFolder object that represents the folder in which a copy of the e-mail message will be saved after being sent.
Upvotes: 3