none
Save mail using outlook plugin RRS feed

  • Question

  • Hi,

    We have a requirement in where we have to save mails in Outlook to our local drive and then invoke a service to import the mail saved in local drive to a DMS system. My query is with the first part. Saving a email in Outlook to my local drive.

    I have developed the plugin in C#. I used below code snippet to save outlook mail item into my local drive. MailItems are getting saved successfully and the content is also exactly the same. But the problem is:

    The size mail file when saved into local using drag-drop is slightly more (3-4 KB) than size of mails saved using the below function. It seems that mail meta-data (To/From/CC/Subject/Mail Server Info/ Message ID etc..) are saved in a different format in the locally saved file while saving using drag-drop. I came to this understanding after comparing the two MSG files in text mode.

    Still can someone confirm if my understanding is correct.

    Outlook.MailItem mailItem = (selObject as Outlook.MailItem);
    if (mailItem != null)
    {
    	string tempMsgFile = tempDir + "\\" + selCount + "_" + String.Join(" ", mailItem.Subject.Split(Path.GetInvalidFileNameChars())) + ".msg";
    	if(!File.Exists("@"+tempMsgFile))
    	{
    	     mailItem.SaveAs(tempMsgFile, Outlook.OlSaveAsType.olMSG);
    	     //...other logic specific to our requirement to invoke service
            }
    }







    Monday, June 20, 2016 4:40 AM

Answers

  • Hi NikhileshJ,

    You are right. This is caused by the different of file format. There are two types for msg file format, olMSG and olMSGUnicode. When you drag and drop to save email, it uses olMSGUnicode file format.

    Best Regards,

    Edward


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    • Marked as answer by NikhileshJ Monday, June 20, 2016 11:33 PM
    Monday, June 20, 2016 9:39 AM

All replies

  • Hi NikhileshJ,

    You are right. This is caused by the different of file format. There are two types for msg file format, olMSG and olMSGUnicode. When you drag and drop to save email, it uses olMSGUnicode file format.

    Best Regards,

    Edward


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    • Marked as answer by NikhileshJ Monday, June 20, 2016 11:33 PM
    Monday, June 20, 2016 9:39 AM
  • Do you get the same results if you omit the second parameter?

    The second parameter is optional. Why do you need to specify the file type to save?

    Anyway, the OlSaveAsType enumeration provides the olMSGUnicode value which stands for Outlook Unicode message format (.msg).


    [custom.development]

    Monday, June 20, 2016 10:57 AM
  • We need to save the emails in native MSG format. To ensure this we are passing the 2nd parameter. :)
    Monday, June 20, 2016 11:36 PM