[英]Change the From Field
我在我的 Outlook 帳戶上設置了一個 Outlook 電子郵件,比如說“example@xxx.com”。
我有另一個“電子郵件帳戶”,比如說“alias@zzz.net”,它只不過是指向我的@xxx.com 帳戶的指針。
Outlook 沒有指針帳戶的設置,除了我能夠在“發件人”字段中鍵入它。 我將 Outlook 設置為手動更改 @xxx.com 和 @zzz.net 之間的 From 字段。
因為我的@xxx.com 電子郵件是實際的電子郵件,所以 Outlook 在“發件人”字段中默認為該電子郵件。 我希望這是相反的,即我發送的任何電子郵件在“發件人”字段中都有“alias@zzz.com”。
我嘗試使用以下代碼:
Public WithEvents myItem As Outlook.MailItem
Private Sub Application_ItemLoad(ByVal Item As Object)
If (TypeOf Item Is MailItem) Then
Set myItem = Item
End If
End Sub
Private Sub FromField()
With myItem
.SentOnBehalfOfName = "alias@zzz.com"
.Display
End With
End Sub
Private Sub myItem_Open(Cancel As Boolean)
FromField
End Sub
將 FromField 子放入 Application_ItemLoad 不起作用。
不能這樣做 - Exchange 在發送外發郵件時始終使用主 SMTP 地址。 作為代理地址之一發送的唯一方法是通過 SMTP 發送。 您可以創建一個虛擬的 POP3/SMTP 帳戶(確保 POP3 不下載郵件)或使用代理管理器- 它直接安裝到 Outlook 中並在幕后透明地使用 SMTP。
有關選項列表,請參閱http://www.msoutlook.info/question/send-mail-from-additional-exchange-address-or-alias 。
您需要使用 MailItem 類的SendUsingAccount屬性,該屬性允許設置一個 Account 對象,該對象表示要發送 MailItem 的帳戶。
Sub SendUsingAccount()
Dim oAccount As Outlook.account
For Each oAccount In Application.Session.Accounts
If oAccount.AccountType = olPop3 Then
Dim oMail As Outlook.MailItem
Set oMail = Application.CreateItem(olMailItem)
oMail.Subject = "Sent using POP3 Account"
oMail.Recipients.Add ("someone@example.com")
oMail.Recipients.ResolveAll
oMail.SendUsingAccount = oAccount
oMail.Send
End If
Next
End Sub
SentOnBehalfOfName屬性僅在 Exchange 帳戶的情況下才有意義。 此外,您需要具有代表其他帳戶發送電子郵件的權限。
不能這樣做 - Exchange 在發送外發郵件時始終使用主 SMTP 地址。 作為代理地址之一發送的唯一方法是通過 SMTP。 您可以創建一個虛擬 POP3/SMTP 帳戶(確保 POP3 不下載郵件)或使用代理管理器(我是它的作者) - 它直接將自身安裝到 Outlook 中並在后台透明地使用 SMTP。
有關選項列表,請參閱http://www.msoutlook.info/question/send-mail-from-additional-exchange-address-or-alias 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.