Share via

Reply to in VBA using Outlook mail

Elsa Piek 20 Reputation points
2026-03-13T14:57:35.26+00:00

I am trying to get emails that I send via Outlook mail to reply to a specific email address. .reply

Can you also change the .from?

I get errors on both of these

Microsoft 365 and Office | Development | Microsoft 365 Developer Program
0 comments No comments

Answer accepted by question author
  1. Vergil-V 11,575 Reputation points Microsoft External Staff Moderator
    2026-03-14T05:32:47.7033333+00:00

    Hi @Elsa Piek   

    As the Q&A Assistant mentioned, the .From property is not writable. To choose a specific sender, you can use .SendUsingAccount

    Note: The sender account must already exist in the Outlook profile. You can verify this under File > Info > Account Information

    Below is a script that creates a reply and sets a specific account as the sender: 

    Sub ReplyWithSpecificAccount() 
        Dim oMail As Outlook.MailItem 
        Dim oReply As Outlook.MailItem 
        Dim oAccount As Outlook.Account 
        Dim sAccountEmail As String 
        
        ' *** SET YOUR DESIRED SENDER ACCOUNT HERE *** 
        sAccountEmail = "SpecificYourAccount" 
        
        ' Get the currently selected email 
        If Application.ActiveExplorer.Selection.Count = 0 Then 
            MsgBox "Please select an email to reply to.", vbExclamation 
            Exit Sub 
        End If 
        
        Set oMail = Application.ActiveExplorer.Selection.Item(1) 
        
        ' Create the reply 
        Set oReply = oMail.Reply 
        
        ' Loop through accounts to find the matching one 
        Dim accountFound As Boolean 
        accountFound = False 
        
        For Each oAccount In Application.Session.Accounts 
            If LCase(oAccount.SmtpAddress) = LCase(sAccountEmail) Then 
                oReply.SendUsingAccount = oAccount 
                accountFound = True 
                Exit For 
            End If 
        Next oAccount 
        
        If Not accountFound Then 
            MsgBox "Account '" & sAccountEmail & "' not found in Outlook." & vbCrLf & _ 
                   "Please check the email address and try again.", vbExclamation 
            Set oReply = Nothing 
            Exit Sub 
        End If 
        
        ' Display the reply for editing before sending 
        oReply.Display 
        
        ' Clean up 
        Set oReply = Nothing 
        Set oMail = Nothing 
        Set oAccount = Nothing 
    End Sub 
    

    Please review this and let me know whether it applies to your situation. 

    If you need any additional support or have questions, feel free to reach out at any time. 


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".         

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Q&A Assist
    2026-03-13T14:57:49.16+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    In Outlook VBA, .Reply creates a reply item and .From cannot be set directly on a MailItem.

    To create a reply and change the sender, use the Reply method to get a reply MailItem, then set its SendUsingAccount (not .From) to one of the accounts configured in Outlook:

    Sub ReplyFromSpecificAccount()
        Dim orig As Outlook.MailItem
        Dim reply As Outlook.MailItem
    
        ' Original message (for example, the currently selected item)
        Set orig = Application.ActiveExplorer.Selection(1)
    
        ' Create the reply
        Set reply = orig.Reply
    
        ' Use a specific account to send the reply
        Dim acc As Outlook.Account
        For Each acc In Application.Session.Accounts
            If acc.SmtpAddress = "service@example.com" Then
                Set reply.SendUsingAccount = acc
                Exit For
            End If
        Next acc
    
        reply.Display   ' or reply.Send
    End Sub
    

    Key points based on the Outlook object model in the context:

    • MailItem.Reply is a method that “creates a reply, pre-addressed to the original sender, from the original message” and returns a MailItem object representing the reply.
    • MailItem.Reply is also exposed as an event (MailItem.Reply event) that fires when the user clicks Reply or the Reply method is called. In the event handler, the reply item is passed as the Response object, and the operation can be canceled by setting Cancel = True.
    • The reply item is always a MailItem object.

    If using the Reply event to adjust the reply before it is shown/sent:

    Public WithEvents myItem As Outlook.MailItem
    
    Sub Initialize_Handler()
        Set myItem = Application.ActiveInspector.CurrentItem
    End Sub
    
    Private Sub myItem_Reply(ByVal Response As Object, Cancel As Boolean)
        Dim reply As Outlook.MailItem
        Set reply = Response
    
        ' Example: change SaveSentMessageFolder
        Set reply.SaveSentMessageFolder = myItem.Parent
    
        ' Here you could also set reply.SendUsingAccount as above
    End Sub
    

    .From is not a writable property on MailItem in this context; use SendUsingAccount to control which mailbox/account sends the reply, and ensure that account is already configured in the Outlook profile.


    References:

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.