古詩詞大全網 - 個性簽名 - OutLook 2010 怎麽用VBA實現:當妳寫完壹封郵件,點擊發送時,判斷有沒有附件

OutLook 2010 怎麽用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