【发布时间】:2016-04-19 16:36:52
【问题描述】:
我正在尝试自动转发邮件,但在此过程中,将 From 字段更改为我们网络中的另一个电子邮件地址,该地址已添加到我的 Outlook(不是作为帐户,而是作为我自己帐户下的邮箱)我可以访问它)
Dim recip As String
Dim allRecips As String
Dim olApp As Outlook.Application
Dim olNs As Namespace
Dim Fldr As MAPIFolder
Dim olMail As Variant
Dim i As Integer
Dim oAccount As Outlook.Account
Set olApp = New Outlook.Application
Set olNs = olApp.GetNamespace("MAPI")
Set Fldr = olNs.Folders("CSR GER").Folders("Inbox").Folders("Folders").Folders("#Confirmations")
i = 1
For Each olMail In Fldr.Items
If InStr(olMail.Subject, "XXX BKG CONFIRMATION: " & BL) <> 0 Then
Set Recipients = olMail.Recipients
For i = Recipients.Count To 1 Step -1
recip$ = Recipients.Item(i).Address
Debug.Print recip$
If VBA.Left(recip$, 10) = "/o=NOL-APL" Then
GoTo Line2
End If
If i = 1 Then
strDomain = strDomain & recip
Else
strDomain = strDomain & recip & "; "
End If
Line2:
Next i
sentby = strDomain
Set myItem = olMail.Forward
myItem.SentOnBehalfOfName = "CSR_EST@xxx.com"
myItem.Recipients.Add sentby
myItem.Display
现在问题在于SentBehalfOfName。一旦myItem.Display 运行,From 字段实际上会正确显示 - CSR_EST@xxx.com 但在发送电子邮件后,您可以看到它是由找到正在转发的电子邮件的邮箱发送的 - “CSR GER”。
谁能帮我理解这里出了什么问题?
【问题讨论】: