送信した電子メールの受信者をスキャンし、外部ドメインの件名を編集するコードを書きました。ただし、電子メール配信リストが含まれている場合は、エラーが発生します。外部ドメインの検索で配信リストのメンバーを処理するにはどうすればよいですか?ここで外部ドメインの電子メール受信者をスキャンする
Private Sub Application_ItemSend(ByVal Item As Object, cancel As Boolean)
Dim strSubject As String
Dim recips As Outlook.Recipients
Dim recip As Outlook.Recipient
Dim pa As Outlook.PropertyAccessor
Dim outsideEmails() As String
Dim includesOutsideDomain As Boolean
Dim i As Integer
Dim userChoice As Integer
Const PR_SMTP_ADDRESS As String = "http://schemas.microsoft.com/mapi/proptag/0x39FE001E"
Set recips = Item.Recipients
ReDim outsideEmails(recips.Count)
strSubject = Item.Subject
includesOutsideDomain = False
i = 0
For Each recip In recips
Debug.Print recip
Set pa = recip.PropertyAccessor
If InStr(LCase(pa.GetProperty(PR_SMTP_ADDRESS)), "@example.com") = 0 Then
outsideEmails(i) = pa.GetProperty(PR_SMTP_ADDRESS)
'On Error Resume Next
includesOutsideDomain = True
End If
Next
If includesOutsideDomain Then
If InStr(LCase(strSubject), "encrypt:") = 0 Then
userChoice = MsgBox("You may be sending this email to an outside domain without encryption. Would you like to encrypt this message?" _
, vbYesNoCancel + vbCritical + vbMsgBoxSetForeground, "Encryption Warning")
Select Case userChoice
Case 6: 'yes
strSubject = "Encrypt:" & strSubject
Item.Subject = strSubject
Case 7: 'no
Case 2: 'cancel
cancel = True
End Select
End If
End If
End Sub
はエラーです:指定されたプロパティが存在しない場合 Error Message
http://www.vbaexpress.com/forum/showthread.php?53174-VBA-to-expand-Outlook-Distribution-Group-before-send前
–