如果您要发送并通过电子邮件发送到外部域,如何让Outlook
向您发出警告?
每天发送大量电子邮件总是可能错误地将错误的人发送给错误的人。当他们是客户或公司以外的人时,这尤其成问题。
使用Alt + Enter
为我打字后快速发送电子邮件通常是因为我没有彻底检查收件人。
我发现了许多不太好的实现,所以我想我会在下面分享我的......
答案 0 :(得分:12)
感谢ojhhawkins提供上述代码 - 非常有用。我做了一个简单的迭代,在MsgBox文本中包含一个外部电子邮件地址列表。
提醒注意 - 我注意到当您在其他程序中使用“发送为电子邮件附件”时不会出现警告,例如Excel,Adobe Reader等。niton指出:
Re:在其他程序中发送电子邮件附件。这里的注释描述outlookcode.com/d/code/setsavefolder.htm“...不适用于使用Office程序中的文件|发送命令或Windows资源管理器或其他程序中的类似命令创建的消息。这些命令调用简单MAPI,绕过Outlook功能。“
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim recips As Outlook.Recipients
Dim recip As Outlook.Recipient
Dim pa As Outlook.PropertyAccessor
Dim prompt As String
Dim strMsg As String
Const PR_SMTP_ADDRESS As String = "http://schemas.microsoft.com/mapi/proptag/0x39FE001E"
Set recips = Item.Recipients
For Each recip In recips
Set pa = recip.PropertyAccessor
If InStr(LCase(pa.GetProperty(PR_SMTP_ADDRESS)), "@example.com") = 0 Then
strMsg = strMsg & " " & pa.GetProperty(PR_SMTP_ADDRESS) & vbNewLine
End If
Next
If strMsg <> "" Then
prompt = "This email will be sent outside of example.com to:" & vbNewLine & strMsg & "Do you want to proceed?"
If MsgBox(prompt, vbYesNo + vbExclamation + vbMsgBoxSetForeground, "Check Address") = vbNo Then
Cancel = True
End If
End If
End Sub
要将此代码实际添加到Outlook应用程序中:
答案 1 :(得分:2)
将以下代码添加到 Outlook &amp;中的Application_ItemSend
事件中将域名更改为您自己的
将Macro Security
更改为(所有宏的通知或启用所有宏)
如果您的TO
,CC
或BCC
地址中有一个或多个不在您的域中(例如,@mycompany.com.au
以下),则会在发送前向您发出警告
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim recips As Outlook.Recipients
Dim recip As Outlook.Recipient
Dim pa As Outlook.PropertyAccessor
Const PR_SMTP_ADDRESS As String = "http://schemas.microsoft.com/mapi/proptag/0x39FE001E"
Set recips = Item.Recipients
For Each recip In recips
Set pa = recip.PropertyAccessor
If InStr(LCase(pa.GetProperty(PR_SMTP_ADDRESS)), "@mycompany.com.au") = 0 Then
If MsgBox("Send mail to external domain?", vbYesNo + vbQuestion + vbMsgBoxSetForeground, "Check Address") = vbNo Then
Cancel = True
Exit Sub
Else
Exit Sub
End If
End If
Next
End Sub
答案 2 :(得分:1)
如果您不想使用VBA,我发现Outlook的两个加载项也是如此,