c# VSTO MailItem.Attachments

c# VSTO MailItem.Attachments

如何检查 MailItem.Attachments 是否已包含具有相同文件路径的附件?

类似于

if (!MailItem.Attachments.Contains("this"){
  //add it
}

Attachments 集合不继承自 System.Collections,因此您不能使用典型的 List 方法。您必须循环(使用 for,而不是 for each with Outlook 对象)通过每个附件来评估 Attachment.FileName 属性.