none
Send As/From Field auto populates based on the address the email was sent to RRS feed

  • Question

  • Hello,

    I have searched for this and can't seem to locate a working solution so here goes.

    I am looking for a solution whether it be an option in outlook, VBA or something else that when replying to an email will make Outlook populate the 'From' field based on the email address that the email being replied to was sent to.

    For example;

    My default account is 'user@domain.com' and I also am a member of a group mailbox with an email address of 'group@domain.com'. When clicking reply to an email sent to the group mailbox outlook will use my default account address in the 'From' field. This confuses people as the reply comes from my individual email address and also any replies sent to my reply come to me and not the group mailbox. I can manually change it to the group address no problem but sometimes I forget to do it.

    What I'm looking to happen is when I click reply to an email Outlook recognises that the email was sent to 'group@domain.com' and sets the 'From' address as such.

    Thanks for any insight on this.

    Tuesday, March 8, 2016 6:43 PM

Answers

  • Hi cd233,

    I made a test with your description, but I failed to reproduce your issue. Anyway, for setting sender mail account while you click reply, I suggest you try the code below:

    Dim WithEvents objInspectors As Outlook.Inspectors
    Dim WithEvents myOlExp As Outlook.Explorer
     Public Sub Initialize_handler()
         Set myOlExp = Application.ActiveExplorer
         Set objInspectors = Application.Inspectors   
     End Sub
    Private Sub myOlExp_InlineResponse(ByVal Item As Object)
    Call SetFromAddress(Item)
    End Sub
    Private Sub objInspectors_NewInspector(ByVal Inspector As Inspector)
         If objMailItem.Sent = False And (Not objMailItem.To = "") Then
             Set objMailItem = Inspector.CurrentItem
             If objMailItem.Sent = False Then
                 Call SetFromAddress(objMailItem)
             End If
         End If
     End Sub
    Public Sub SetFromAddress(oMail As Outlook.MailItem)
         Dim oAccount As Outlook.Account
         For Each oAccount In Application.Session.Accounts
            If oAccount = "group@domain.com" Then
                oMail.SendUsingAccount = oAccount
            End If
         Next
     End Sub

    Best Regards,

    Edward


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Thursday, March 10, 2016 2:58 AM

All replies

  • Hi,

    Based on my knowledge, there is no settings in Outlook to meet your requirement. To confirm if your requirement can be achieved by development tools, we would help you move this thread to general Office Development forum. And hope you can find the solution here.

    Regards,


    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact tnmff@microsoft.com.

    Winnie Liang
    TechNet Community Support

    Wednesday, March 9, 2016 9:14 AM
  • Hello,

    You can develop a VBA macro or COM add-in. Note, VBA macros are not designed for distributing them on multiple PCs. So, if you need to deploy the solution on multiple machines I'd recommend developing a COM add-in. 

    The Outlook object model provides the SendUsingAccount property which allows to set an Account object that represents the account under which the MailItem is to be sent. The SendUsingAccount property can be used to specify the account that should be used to send the MailItem when the Send method is called.

    For example, take a look at the How to: Send an E-Mail Given the SMTP Address of an Account article which provides a sample code.

    Wednesday, March 9, 2016 11:30 AM
  • Hi,

    Thanks for the info. I don't need to distribute on a large scale this as it will just be used by myself on a couple of machines.

    I've wrote VBA before, not to an advanced level but I'm willing to give it a shot! Is there a way to trigger the code when clicking reply to an email?

    I'd also be interested if something could be developed for OWA as I use Office 365 Outlook with Exchange server.

    Thanks again for any insight on this.

    Wednesday, March 9, 2016 4:55 PM
  • Hi cd233,

    I made a test with your description, but I failed to reproduce your issue. Anyway, for setting sender mail account while you click reply, I suggest you try the code below:

    Dim WithEvents objInspectors As Outlook.Inspectors
    Dim WithEvents myOlExp As Outlook.Explorer
     Public Sub Initialize_handler()
         Set myOlExp = Application.ActiveExplorer
         Set objInspectors = Application.Inspectors   
     End Sub
    Private Sub myOlExp_InlineResponse(ByVal Item As Object)
    Call SetFromAddress(Item)
    End Sub
    Private Sub objInspectors_NewInspector(ByVal Inspector As Inspector)
         If objMailItem.Sent = False And (Not objMailItem.To = "") Then
             Set objMailItem = Inspector.CurrentItem
             If objMailItem.Sent = False Then
                 Call SetFromAddress(objMailItem)
             End If
         End If
     End Sub
    Public Sub SetFromAddress(oMail As Outlook.MailItem)
         Dim oAccount As Outlook.Account
         For Each oAccount In Application.Session.Accounts
            If oAccount = "group@domain.com" Then
                oMail.SendUsingAccount = oAccount
            End If
         Next
     End Sub

    Best Regards,

    Edward


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Thursday, March 10, 2016 2:58 AM