|
在outlook的ThisOutlookSession中添加如下代码即可:
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
On Error Resume Next
Dim message As Outlook.MailItem
Set message = Item
If Not CheckAttachment(message) Then
Cancel = True
Exit Sub
End If
If Not CheckSubject(message) Then
Cancel = True
Exit Sub
End If
End Sub
Private Function CheckAttachment(message As Outlook.MailItem) As Boolean
CheckAttachment = True
If (message.Attachments.Count = 0 And _
(InStr(message, "附件") > 0 Or InStr(message.Body, "附件") > 0)) Then
Dim answer As VbMsgBoxResult
answer = MsgBox("没有附件, 是否继续发送?", vbYesNo + vbQuestion, "Microsoft Office Outlook")
If answer = vbNo Then
CheckAttachment = False
Else
CheckAttachment = True
End If
End If
End Function
Private Function CheckSubject(message As Outlook.MailItem) As Boolean
CheckSubject = True
If message.Subject = "" Then
Dim answer As VbMsgBoxResult
answer = MsgBox("没有主题, 是否继续发送?", vbYesNo + vbQuestion, "Microsoft Office Outlook")
If answer = vbNo Then
CheckSubject = False
Else
CheckSubject = True
End If
End If
End Function
[ 本帖最后由 zealot30 于 2009-11-6 21:20 编辑 ] |
|