简体   繁体   中英

VBA / Outlook 2010 - Reply / Reply to All from Default Mail Address

with the below VBA code I was able to create a new button on the Outlook 2010 ribbon from which I can send emails with my default email address.

Now I want to have a similar button on the Outlook 2010 ribbon for "replying / replying all". Outlook selects, when "replying" or "replying all", by default the mail address as sender the mail came into but I would like to send all my emails with the default email address.

That's the VBA script I used to which I found in that tutorial here: http://www.sevenforums.com/tutorials/129318-outlook-2010-always-send-default-account.html

Public Sub New_Mail()
Dim oAccount As Outlook.Account
Dim oMail As Outlook.MailItem
For Each oAccount In Application.Session.Accounts
If oAccount = "Name of Default Account" Then
Set oMail = Application.CreateItem(olMailItem)
oMail.SendUsingAccount = oAccount
oMail.Display
End If
Next
End Sub

Any ideas how to change the above code or does anyone have an idea how I can create such buttons on the outlook ribbon for "replying" emails?

Thank you!

I was able to solve it finally! That's the code below:

Public Sub Reply_Mail()
Dim oAccount As Outlook.Account
Dim oMail As Outlook.MailItem

For Each oAccount In Application.Session.Accounts

If oAccount = "Name of your mail address" Then
    Set oMail = Application.ActiveExplorer.Selection(1).Reply
      oMail.SendUsingAccount = oAccount
    oMail.Display
End If
Next

End Sub

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