• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 858
  • Last Modified:

VBA to send email from specific account


Hoping someone can help. I have VBA code that runs in MS Access to send out emails via Outlook. It currently defaults to sending the email from the user's default account, but I want it to send the emails from a shared account that all the user's have access to. I've seen there's an object called .sendusingaccount but I'm struggling to get it working. Please can someone advise. Code is below (for some reason I can't seem to embed it in the message so have just copied into message).

Many thanks in advance.

    'Create the message.
    Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
    With objOutlookMsg
        'Add the To recipient(s) to the message.
        Set objOutlookRecip = .Recipients.Add(Name:=var_Sender)
        objOutlookRecip.Type = olTo

        'Set the Subject, Body, and Importance of the message.
        .Subject = "PIN Reminder Request Ref." & var_RequestID
        .Body = var_Message2 & vbCrLf & vbCrLf
        .Importance = olImportanceHigh  'High importance

        'Resolve each Recipient's name.
        For Each objOutlookRecip In .Recipients
    End With
1 Solution
Above your .Subject line place the below line.

.SentOnBehalfOfName = "me@myaddress.com"
Jeffrey CoachmanMIS LiasonCommented:
Begbie76Author Commented:
Thank you. That one line of code did the trick.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now