简体   繁体   中英

Change the From Field

I have a single Outlook email set up on my Outlook account, let's say "example@xxx.com".

I have another "email account", let's say "alias@zzz.net", that serves as nothing more than a pointer to my @xxx.com account.

Outlook has no settings for the pointer account other than my ability to type it into the From field. I have Outlook set up to manually change the From field between @xxx.com and @zzz.net.

Because my @xxx.com email is the actual email, Outlook defaults to that email in the From field. I would like this to be the opposite, ie any email I send out has "alias@zzz.com in the From field.

I have attempted with the following code:

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

Placing the FromField sub into the Application_ItemLoad did not work.

Cannot do that - Exchange always uses the primary SMTP address when sending the outgoing messages. The only way to send as one of the proxy addresses is to do that through SMTP. You can either create a dummy POP3/SMTP account (make sure POP3 does not download the messages) or use Proxy Manager - it installs itself directly into Outlook and transparently uses SMTP under the hood.

See http://www.msoutlook.info/question/send-mail-from-additional-exchange-address-or-alias for the list of options.

You need to use the SendUsingAccount property of the MailItem class which allows to set an Account object that represents the account under which the MailItem is to be sent.

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 

The SentOnBehalfOfName property makes sense only in case of Exchange account. Moreover, you need to have permissions to send emails on behalf of other accounts.

Cannot do that - Exchange always uses the primary SMTP address when sending the outgoing messages. The only way to send as one of the proxy addresses is to do that through SMTP. You can either create a dummy POP3/SMTP account (make sure POP3 does not download the messages) or use Proxy Manager (I am its author) - it installs itself directly into Outlook and transparently uses SMTP under the hood.

See http://www.msoutlook.info/question/send-mail-from-additional-exchange-address-or-alias for the list of options.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM