如何在 Outlook 邮件项目中将被阻止的文件类型添加为附件?

How to add blocked file types as attachments in an outlook mail item?

我正在尝试从邮件中提取附件并将​​这些文件附加到另一个邮件项目。

一切正常,但如果我尝试添加一个扩展名被阻止的附件,附件将不会添加到邮件项目中。以下是我所做的:

private void addAttachments( Redemption.RDOMail sourceMail , ref Redemption.RDOMail targetMail )                
{
    foreach (Redemption.RDOAttachment attachment in sourceMail.Attachments)
    {
        // Saving attachment files from source mail on local disk 
        attachment.SaveAsFile(/*File Path*/);

        // adding attachment to target mail from saved location
        //At this point, target mail has the attachment count incremented
        targetMail.Attachments.Add(/*File PAth*/ + attachment.DisplayName);

        // deleting file, saved on local disk
        File.Delete(/*File Path + attachment.DisplayName*/);                   
    }

    targetMail.Save();

    // when the mail item is being displayed, the added attachment with the *.EXE,
    //or all the other attachment extentions which are blocked from viewing by outlook is gone.
    // This does not happen for other attachment files
    targetMail.Display();
}

为什么这些特定的附件类型不会显示?

Why these particular attachment types won't get displayed?

那是Microsoft Office feature,不是你的软件坏了。

根据 Microsoft 的说法,有以下三种选择:

  • 使用共享服务器
  • 使用文件压缩实用程序
  • 重命名文件

我想添加第四个:

我会选择选项 2,因为这是最容易实现的,并且不需要更改发送方和接收方 PC(您无法始终控制它们并且可能具有安全隐患)。