无法从 Outlook.MailItem 中删除附件

发布于 2024-11-27 14:55:35 字数 572 浏览 0 评论 0原文

我的 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 删除所有附件(在用户发送邮件之前)并取消发送?

万分感谢!

Mojo

My Outlook addin checks (when user click "send") if a large attachment is attached. If so it should remove it and cancel the sending and give focus back to the user.

Here's a sample of my Outlook addin code...

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

The active mail item still shows all the attachements. :(

How do I get Outlook to remove all the attachments (before user sends the mail) and cancel the sending?

Thanks a million!

Mojo

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

春风十里 2024-12-04 14:55:35

试试这个:

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

Try this:

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
活泼老夫 2024-12-04 14:55:35

我知道老问题,但我在 Outlook 2010 中遇到了同样的问题并解决了。删除或删除对我都不起作用,直到我添加:

mail.Save

Old question I know but I have the same problem with Outlook 2010 and solved it. Neither Delete nor Remove worked for me until I added:

mail.Save
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文