mailItem.SaveAs(savepath);
Where mailItem is Outlook MailItem, and the save path, for example:
String savepath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + @"\" + filename + ".msg";
If you want to use the MailItem theme as the file name, you can remove the invalid characters for the file names:
String filename = mailItem.Subject;
string invalid = new string(Path.GetInvalidFileNameChars()) + new string(Path.GetInvalidPathChars());
foreach (char c in invalid)
{
filename = filename.Replace(c.ToString(), "");
}
source
share