Outlook automation SaveAs method hangs

Y

Yashgt

Hi,

We are trying to programmtically build a MailItem object in a .NET
program and trying to save it as a .msg file. The code works up to the
point of the SaveAs call, where it hangs indefinitely. What could be
the issue? Please see the code below. We have ensured that no other
instance of Outlook.exe is running when we run our program.

Outlook.Application OutlookApplication = new Outlook.Application();
Outlook.NameSpace olNamespace =
OutlookApplication.GetNamespace("MAPI");
olNamespace.Logon(null, null, false, false);

Outlook.MailItem newMail =
(Outlook.MailItem)OutlookApplication.CreateItem(Outlook.OlItemType.olMailItem);
newMail.To = "(e-mail address removed)";
newMail.Subject = objEmailQueueLog.EmailTemplateSubject;
newMail.Body = objEmailQueueLog.EmailTemplateBody;
newMail.SaveAs(@"C:\aa.msg", Outlook.OlSaveAsType.olMSG);
newMail = null;
olNamespace.Logoff();
olNamespace = null;

Thanks,
Yash
 

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

Similar Threads


Top