Sending e-mails from specific email address

D

daniel.bonallack

I am preparing code that sends e-mails via Outlook, but gets the data it needs from an Excel spreadsheet. It loops through rows in Excel to get the fields it needs.

The code to send e-mails is below. However, I want the e-mail to be sent from a separate account that I have access to.

Currently, it always sends from (e-mail address removed) (my default).
But I want to send from (e-mail address removed) (another account I can access via Outlook)

Any help appreciated.

Daniel
____

Sub SendEmails()

Dim OutApp As Object
Dim OutMail As Object

Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)

mySalutation = "Dear " & Cells(iEmail, 2).Value & ","

On Error Resume Next
With OutMail
.To = Cells(iEmail, 5).Value
.CC = ""
.BCC = ""
.Subject = cells(iMail, 6).value
.Body = mySalutation & Chr(10) & Chr(10) & myBody
.Send
End With
On Error GoTo 0

Set OutMail = Nothing
Set OutApp = Nothing

End Sub
 
S

seanryanie

Try using

..SendUsingAccount = OutApp.Session.Accounts.Item(1)

Just alter to whatever the A/c number is eg

..SendUsingAccount = OutApp.Session.Accounts.Item(2)
..SendUsingAccount = OutApp.Session.Accounts.Item(3)
etc etc
 
D

daniel.bonallack

Try using .SendUsingAccount = OutApp.Session.Accounts.Item(1) Just alter to whatever the A/c number is eg .SendUsingAccount = OutApp.Session.Accounts.Item(2) .SendUsingAccount = OutApp.Session.Accounts.Item(3) etc etc

Thank you very much!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top