0
votes

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
1

1 Answers

1
votes

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