【发布时间】:2021-02-23 23:53:41
【问题描述】:
我在 Outlook 上只有一个交换帐户,可以访问两个由管理员创建的共享/组邮箱或邮件地址。我只是该共享邮件组的成员,我可以通过它们发送和接收邮件。所以有时我会因为选择错误的发件人地址而犯错误。在发送电子邮件之前,我需要检查发件人/发件人地址和收件人。但是,我无法通过 VBA 将发件人/发件人地址作为字符串返回。我通过“来自”下拉菜单选择它们。
这是我的代码:
Dim Recipients As Outlook.Recipients
Dim recip As Outlook.Recipient
Dim i
Dim prompt As String
Dim Send_Address As String
Dim checker As Integer
Send_Address = Item.SendUsingAccount.SmtpAddress
checker = 0
Set Recipients = Item.Recipients
For i = Recipients.Count To 1 Step -1
Set recip = Recipients.Item(i)
If InStr(LCase(recip.Address), "abc.com") Then
checker = 1
End If
If InStr(LCase(recip.Address), "xyz.com") Then
checker = 2
End If
Next i
If (Send_Address = "abc.om") And (checker = 1) Then
MsgBox ("Please check CC list. It includes different clients.")
Cancel = True
ElseIf (Send_Address = "xyz.com") And (checker = 2) Then
MsgBox ("Please check CC list. It includes different clients.")
Cancel = True
Else
MsgBox ("OK" & checker & Send_Address)
Cancel = True
End If
End Sub
【问题讨论】:
-
使用 SendUsingAccount 属性有什么问题?