|
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
'Dim abc As Outlook.mailItem
' abc = Set_Account("m", Item)
Dim objRecip As Recipient
Dim objContact As ContactItem
Dim strExternal As String
Dim cancel_Subject As Boolean
Dim cancel_Attach As Boolean
If Item.Subject = "" Then
cancel_Subject = MsgBox("此封邮件没有标明主题" & vbNewLine & _
"是否继续发送?", _
vbYesNo + vbExclamation, "空主题") = vbNo
End If
Dim intRes As Integer
Dim strMsg As String
Dim strThismsg As String
Dim intOldmsgstart As Integer
Dim sSearchStrings(2) As String
Dim bFoundSearchstring As Boolean
Dim i As Integer
bFoundSearchstring = False
sSearchStrings(0) = "attach"
sSearchStrings(1) = "enclose"
sSearchStrings(2) = "附件"
intOldmsgstart = InStr(Item.Body, "-----Original Message-----")
If intOldmsgstart = 0 Then
strThismsg = Item.Body + " " + Item.Subject
Else
strThismsg = Left(Item.Body, intOldmsgstart) + " " + Item.Subject
End If
For i = LBound(sSearchStrings) To UBound(sSearchStrings)
If InStr(LCase(strThismsg), sSearchStrings(i)) > 0 Then
bFoundSearchstring = True
Exit For
End If
Next i
If bFoundSearchstring Then
If Item.Attachments.count = 0 Then
strMsg = "附件检测器:" & Chr(13) & Chr(10) & "此邮件中提及附件,是否已经添加附件?" & Chr(13) & Chr(10) & "是否要发送?"
intRes = MsgBox(strMsg, vbYesNo + vbDefaultButton2 + vbExclamation, "你忘记添加附件!")
If intRes = vbNo Then
cancel_Attach = True
End If
End If
End If
Dim strTo As String
Dim strCC As String
Dim strBCC As String
strTo = ""
strCC = ""
strBCC = ""
If (cancel_Subject Or cancel_Attach) = True Then
Cancel = True
End If
If Item.MessageClass Like "IPM.TaskRequest*" Then
Set Item = Item.GetAssociatedTask(False)
End If
strExternal = ""
For Each objRecip In Item.Recipients
' Set objContact = FindContactByAddress(objRecip.Address)
' If objContact Is Nothing Then
' If LCase(objRecip.Address) Like "/o=*" Then
' strExternal = strExternal & "内部邮件地址: " & objRecip.Name & vbCr
' Else
' strExternal = strExternal & "外部邮件地址: " & objRecip.Name & vbCr
' End If
' End If
If Not LCase(objRecip.Address) Like "/o=*" Then
If InStr(1, Item.To, objRecip.Name) <> 0 Then
strTo = strTo + objRecip.Name
ElseIf InStr(1, Item.CC, objRecip.Name) <> 0 Then
strCC = strCC + objRecip.Name
ElseIf InStr(1, Item.BCC, objRecip.Name) <> 0 Then
strBCC = strBCC + objRecip.Name
End If
End If
Next
MSGText = "主题:「" & Item.Subject & "」" & vbCr & "要向下面的地址发送邮件,确定吗?" & _
vbLf & "收信人地址:" & vbCr & strTo & vbCr & " 抄送 : " & strCC & vbCr & " 密送 : " & strBCC
If MsgBox(MSGText, vbYesNo, "发送确认") = vbNo Then
Cancel = True
End If
End Sub |
|