JenkinsM82
New Member
- Joined
- May 17, 2018
- Messages
- 9
Hi Everyone! I'm struggling with some Excel VBA and was wondering if anyone had any suggestions for me. I'm using the code below to send out email. It works great except for people who have multiple email profiles setup in Outlook. I was trying to set Email_Send_From as one of the "from" email address, but it always defaults to the primary email account in Outlook.
Code:
Dim Email_Subject, Email_Send_From, Email_Send_To, Email_Cc, Email_Bcc, Email_Body As String
Dim Mail_Object, Mail_Single As Variant
Email_Subject = "Subject"
Email_Send_From = "[MY EMAIL ADDRESS]"
Email_Send_To = Sheets("Order").Range("email").Value
Email_Cc = ""
Email_Bcc = ""
Email_Body = "Email Body"
On Error GoTo ErrorHandler
Set Mail_Object = CreateObject("Outlook.Application")
Set Mail_Single = Mail_Object.CreateItem(0)
With Mail_Single
.Display
.Subject = Email_Subject
.To = Email_Send_To
.cc = Email_Cc
.BCC = Email_Bcc
'.From = Email_Send_From
.HTMLBody = Email_Body & .HTMLBody
.Attachments.Add ("File Path")
End With