如何直接打开Outlook文件附件而不保存? (使用 C# VSTO)
How to Open Outlook file attachment directly not saving it? ( with C# VSTO)
我需要直接从邮件中打开邮件文件附件。假设我有 .txt 文件。我已经把它附加到我的邮件中了。但是现在我需要打开它,更改一些词并保存它(它是手动部分)。我怎样才能做到这一点?我的代码是:
private void button2_Click(object sender, EventArgs e)
{
Outlook.Inspector currInspector = null;
Outlook.MailItem mail = null;
Outlook.Attachments attachments = null;
currInspector = Globals.ThisAddIn.Application.ActiveInspector();
if (currInspector != null) {
mail = (Outlook.MailItem)currInspector.CurrentItem;
attachments = mail.Attachments;
attachments.Add(@"C:\install\CSharp\tulemus.txt", Outlook.OlAttachmentType.olByValue);
}
Outlook 对象模型不为此提供任何 属性 或方法。您可以尝试从 Outlook 维护的缓存文件夹中读取附件。有关详细信息,请参阅 Finding Outlook temporary folder for email attachments。
此外,您可以使用低级 API(扩展 MAPI),您可以在其中访问 PR_ATTACH_DATA_BIN property, read more about the algorithm in the Opening an attachment 文章。
除了 Eugene 的建议之外 - 使用 Attachment.PropertyAccessor
或 MAPI(C++ 或 Delphi)访问 PR_ATTACH_DATA_BIN
属性(DASL 名称 "http://schemas.microsoft.com/mapi/proptag/0x37010102"
) - 您还可以使用 Redemption(我是它的作者):它的 RDOAttach.AsText
/ AsArray
/ AsStream
属性允许动态修改附件内容
我需要直接从邮件中打开邮件文件附件。假设我有 .txt 文件。我已经把它附加到我的邮件中了。但是现在我需要打开它,更改一些词并保存它(它是手动部分)。我怎样才能做到这一点?我的代码是:
private void button2_Click(object sender, EventArgs e)
{
Outlook.Inspector currInspector = null;
Outlook.MailItem mail = null;
Outlook.Attachments attachments = null;
currInspector = Globals.ThisAddIn.Application.ActiveInspector();
if (currInspector != null) {
mail = (Outlook.MailItem)currInspector.CurrentItem;
attachments = mail.Attachments;
attachments.Add(@"C:\install\CSharp\tulemus.txt", Outlook.OlAttachmentType.olByValue);
}
Outlook 对象模型不为此提供任何 属性 或方法。您可以尝试从 Outlook 维护的缓存文件夹中读取附件。有关详细信息,请参阅 Finding Outlook temporary folder for email attachments。
此外,您可以使用低级 API(扩展 MAPI),您可以在其中访问 PR_ATTACH_DATA_BIN property, read more about the algorithm in the Opening an attachment 文章。
除了 Eugene 的建议之外 - 使用 Attachment.PropertyAccessor
或 MAPI(C++ 或 Delphi)访问 PR_ATTACH_DATA_BIN
属性(DASL 名称 "http://schemas.microsoft.com/mapi/proptag/0x37010102"
) - 您还可以使用 Redemption(我是它的作者):它的 RDOAttach.AsText
/ AsArray
/ AsStream
属性允许动态修改附件内容