我的Outlook插件检查(当用户点击“发送”时)如果附加了大附件。如果是这样,它应该将其删除并取消发送并将焦点反馈给用户。
以下是我的Outlook插件代码示例...
Private Sub ThisApplication_ItemSend(ByVal Item As Object, ByRef Cancel As Boolean) Handles Application.ItemSend
Dim mail As Outlook.MailItem = CType(Me.Application.ActiveInspector.CurrentItem, Outlook.MailItem)
For i As Integer = mail.Attachments.Count To 1 Step -1
mail.Attachments.Remove(i)
Next
Cancel = True
End Sub
活动邮件项目仍会显示所有附件。 :(
如何让Outlook删除所有附件(在用户发送邮件之前)并取消发送?
万分感谢!
魔
答案 0 :(得分:1)
试试这个:
Private Sub Application_ItemSend(ByVal Item As Object, ByRef Cancel As Boolean) Handles Application.ItemSend
Dim mail As Outlook.MailItem = CType(Me.Application.ActiveInspector.CurrentItem, Outlook.MailItem)
For Each a As Outlook.Attachment In mail.Attachments
a.Delete()
Next
Cancel = True
End Sub
答案 1 :(得分:1)
旧问题我知道,但我在Outlook 2010中遇到了同样的问题并解决了它。在我添加之前,删除和删除都没有为我工作:
mail.Save