【问题标题】:Warn when sending mail outside of local domains在本地域之外发送邮件时发出警告
【发布时间】:2016-04-01 21:41:23
【问题描述】:

我有以下代码检查您发送的电子邮件是否在我们的本地域中,如果不是,它将提示您确认是/否。

我想更改它以检查一些其他内部域,因此它不会提示这些域的消息。

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)), "@domain.com.au") = 0 Then
strMsg = strMsg & "   " & pa.GetProperty(PR_SMTP_ADDRESS) & vbNewLine
End If
Next
For Each recip In recips
Set pa = recip.PropertyAccessor
If InStr(LCase(pa.GetProperty(PR_SMTP_ADDRESS)), "@domain.com.au") = 0 Then
prompt = "This email will be sent outside of domain.com.au to:" & vbNewLine & strMsg & "Do you want to proceed?"
If MsgBox(prompt, vbYesNo + vbExclamation + vbMsgBoxSetForeground, "Check Address") = vbNo Then
    Cancel = True
    Exit Sub
Else
    Exit Sub
End If
End If
Next
End Sub

【问题讨论】:

    标签: vba outlook


    【解决方案1】:

    通过简单的AND条件解决。

    If InStr(LCase(pa.GetProperty(PR_SMTP_ADDRESS)), "@domain.com.au") = 0 AND InStr(LCase(pa.GetProperty(PR_SMTP_ADDRESS)), "@domaintwo.com.au") Then
    

    【讨论】:

      猜你喜欢
      • 2013-07-19
      • 2018-12-12
      • 1970-01-01
      • 2017-06-07
      • 2016-12-01
      • 2015-06-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多