在内存而不是文件系统中将 MailItem 转换为 MSG

Convert MailItem to MSG in memory rather than filesystem

目前我正在通过将 mailItem 写入 MSG 文件来对 mailItem 进行 base64 编码:

 mailItem.SaveAs(@"c:\path\to\save\mail.msg", Outlook.OlSaveAsType.olMSG);
 FileStream fs = new FileStream( fullPath, FileMode.Open, FileAccess.Read );
 byte[] filebytes = new byte[fs.Length];
 fs.Read( filebytes, 0, Convert.ToInt32( fs.Length ) );
 string encodedData = Convert.ToBase64String( filebytes, 
 Base64FormattingOptions.InsertLineBreaks );

我找了很久也没有找到不把 MSG 写入硬盘的方法。

有没有什么方法可以在不需要写入硬盘的情况下执行此操作?

谢谢!

Per Justin Cooney(强调他的):

The Outlook.MailItem object is in fact a COM object that cannot be dynamically saved/loaded. To achieve the desired save/load functionality the Outlook.MailItem object will first need to be converted to a .MSG file.

这也是我想做的事情,可惜受限于上面的限制。我目前正在将文件写入临时位置,传递路径,转换为 Base64 字符串并在成功后删除文件。

不,没有使用 OOM。在扩展 MAPI(C++ 或 Delphi)中是可能的。