【发布时间】:2019-05-17 16:54:35
【问题描述】:
我有一封邮件,其中仅包含签名作为图像和如下截图所示的附件。
我将此电子邮件保存为C:\mail.msg,然后我尝试通过以下代码阅读它:
var oApp = new Microsoft.Office.Interop.Outlook.Application();
MailItem outlookMsg = (Microsoft.Office.Interop.Outlook.MailItem)oApp.CreateItemFromTemplate(@"C:\mail.msg");
//there are 2 attachments inside
foreach(var att in outlookMsg.Attachments)
{
att.SaveAsFile($@"C:\{att.FileName}");
}
问题
MailItem 内有 2 个附件,命名为:
-empty.xlsx
-lot4.xlsx
如果我把lot4.xlsx的扩展名改成lot4.png,就可以作为签名中的图片打开了。
在添加名称不正确的附件时,有人见过这种奇怪的情况吗?
【问题讨论】:
-
具体来说,您是如何查询文件名/扩展名的?您能否向我们展示您用于读取/检查名称的代码和属性?这要么是您偶然发现的 Outlook 互操作 API 中的一个非常奇怪的错误,要么是您自己代码中其他地方的一些问题。
-
@JᴀʏMᴇᴇ 当我保存文件时,我可以检查名称