OutLook 2010 怎么用VBA实现:当你写完一封邮件,点击发送时,判断有没有附件
如果已经有附件了,则直接发送出去;如果没有附件,则弹出一个对话框,询问是否忘记粘贴附件了,点击是,返回继续写邮件,点击否,则发送出去。
我用了有没有人经常忘加附件?(VBA提醒)这篇文章里的代码,没有任何效果,跟直接发送邮件一样。
我写了一段代码,但是无法判断有没有附件,不论粘贴没粘贴附件,总是提醒,
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean) Dim myOlApp As New Outlook.Application Dim myItem As Outlook.MailItem Dim myAttachments As Outlook.Attachments Dim cancelsend As Long Set myItem = myOlApp.CreateItem(olMailItem) Set myAttachments = myItem.Attachments If myItem.Attachments.Count = 0 Then cancelsend = MsgBox(" 是否忘记粘贴附件了 !" & vbNewLine & vbNewLine & " 确定要发送吗?", _ vbYesNo + vbDefaultButton2 + vbQuestion, "忘记粘贴附件提示") If cancelsend = vbNo Then Cancel = True End If End Sub
现在的问题是,If myItem.Attachments.Count = 0 Then 这条语句里的值始终为0,不管粘贴多少附件,还是0,怎么办?谢谢回答!
|