我正在尝试解析基于文本的文件附件(txt、doc 等)。但是,我似乎无法获取二进制信息本身。我可以获取文件名,我可以将文件保存到某个临时文件夹并从那里打开它,但这似乎很乱。
有什么方法可以访问附件的内容而不保存它,阅读它,然后删除它还是我只是在追我的尾巴?
我正在尝试解析基于文本的文件附件(txt、doc 等)。但是,我似乎无法获取二进制信息本身。我可以获取文件名,我可以将文件保存到某个临时文件夹并从那里打开它,但这似乎很乱。
有什么方法可以访问附件的内容而不保存它,阅读它,然后删除它还是我只是在追我的尾巴?
Redemption 将在这里为您提供帮助,SafeMailItem.Attachments 集合具有 Attachment 对象,该对象具有属性“AsText”签出
http://www.dimastr.com/redemption/
76梅尔
您可以使用 Microsoft 架构获取附件的内容 -
private void GetAttachmentContent(Attachments attachments)
{
foreach (Attachment attachment in attachments)
{
//microsoft schema to get the attachment content
string AttachSchema = "http://schemas.microsoft.com/mapi/proptag/0x37010102";
byte[] filebyte = (byte[])attachment.PropertyAccessor.GetProperty(AttachSchema);
}
}
您需要参考:代码文件中的 Microsoft.CSharp.dll