VBA to send email from specific account

Hello

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
            objOutlookRecip.Resolve
        Next
            .Save
            .Send
   
    End With
Begbie76Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

MikeMcEvoyCommented:
Above your .Subject line place the below line.

.SentOnBehalfOfName = "me@myaddress.com"
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Jeffrey CoachmanMIS LiasonCommented:
0
Begbie76Author Commented:
Thank you. That one line of code did the trick.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.