P
PromisedOyster
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 address 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.
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 address 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.