Create the message as a post item (olPostItem) rather than olMailItem - it
will be created in the sent state, then change the MessageClass property to
"IPM.Note". You will need to change the icon as well, but you will need
Extended MAPI/CDO 1.21/Redemption for that: see
http://www.dimastr.com/redemption/faq.htm#8
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
"PromisedOyster" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> We have an application that automatically sends and saves Outlook
> messages. However, what I want to do is somehow get the MSG file to be
> marked as 'sent' rather than 'not sent'.
>
> Outlook.Application outlook = null;
> Outlook.MailItem mailItem = null;
>
> try
> {
> object o = Marshal.GetActiveObject("Outlook.Application");
> outlook = o as Outlook.Application;
> }
> catch
> {
> // unable to connect to open version of Outlook. Create new instance
> outlook = new Outlook.ApplicationClass();
> }
>
> Object omailItem = outlook.CreateItem(Outlook.OlItemType.olMailItem);
> mailItem = omailItem as Outlook.MailItem;
> mailItem.To = "(E-Mail Removed)";
> mailItem.Subject = "Test email";
>
> // The following two lines of code generates the exception:
> //An unhandled exception of type
> 'System.Runtime.InteropServices.COMException' occurred in TestEmail.exe
> // Additional information: The item has been moved or deleted.
>
> // mailItem.Send();
> //mailItem.SaveAs("C:\\temp\\TestEmail.MSG",
> Outlook.OlSaveAsType.olMSG);
>
> // The following two lines of code saves and sends the email, but the
> MSG file says not semt
> mailItem.SaveAs("C:\\temp\\TestEmail.MSG", Outlook.OlSaveAsType.olMSG);
> mailItem.Send();
>
> What is the simplest way of getting the sent MSG (to save to file) so
> it is clear that the MSG has actually been sent?
>
>
> Your assistance would be greatly appreciated.
>