user2242044
user2242044

Reputation: 9213

VBA Send Email from Second Outlook Email Address

I am using the following code to send emails through Outlook using VBA in Excel. I have two emails addresses set up in Outlook. I'd like to send the email from my secondary email account. How would I do that?

 Dim objOL
Dim objAppt
Const olAppointmentItem = 1
Const olMeeting = 1

    Set objOL = CreateObject("Outlook.Application")
    Set objAppt = objOL.CreateItem(0)

     With objAppt
    .display
    End With
     signature = objAppt.HTMLBody
    With objAppt
        .to = Range("H3").Value
        .Subject = Range("L3").Value
        .CC = Range("K3").Value

        .HTMLBody = Body
        .display 'display not send
    End With

    Set objAppt = Nothing
    Set objOL = Nothing

Upvotes: 0

Views: 687

Answers (1)

Dmitry Streblechenko
Dmitry Streblechenko

Reputation: 66235

Set the MailItem.SendUsingAccount property to one of the Account objects from the Namespace.Accounts collection.

Upvotes: 1

Related Questions