This project has moved and is read-only. For the latest updates, please go here.

Save Current Mail Item

Aug 10, 2015 at 11:30 AM
Edited Aug 10, 2015 at 11:49 AM
     Its my first time creating an addin for outlook. I want to save the current mail item to the downloads folder but my code doesnt seem to work(it saves a type "file", i need .msg). Can anyone have a look at this?
        public void SendButton_Click(Office.IRibbonControl control)
                var inspector= GlobalModule.ActiveInspector();
                var mail = test.CurrentItem as MailItem;
                string userRoot = System.Environment.GetEnvironmentVariable("USERPROFILE");
                string downloadFolder = Path.Combine(userRoot, "Downloads");
                mail.SaveAs(downloadFolder + @"\test", OlSaveAsType.olMSG);
                MessageBox.Show(downloadFolder, " ", MessageBoxButtons.OK, MessageBoxIcon.Information);
            catch (System.Exception e)
                MessageBox.Show(string.Format("Error in Addins: {0}", e.ToString()), " ", MessageBoxButtons.OK, MessageBoxIcon.Error);
Thank you in advance :)
Sep 29, 2015 at 11:41 AM
You should add extension ".msg" to let Windows know that it is message file.
mail.SaveAs(downloadFolder + @"\test.msg", OlSaveAsType.olMSG);