1 min readfrom Microsoft Excel | Help & Support with your Formula, Macro, and VBA problems | A Reddit Community

Default address not used when using VBA to send Excel PDF using Outlook

I have 3 email accounts: 1 for each of my 2 businesses and 1 for personal use. I have the default email address set to my older business email address, but when I send an email using this VBA code it sends an email including part of a spreadsheet saved as a PDF from my personal account. This wasn't a problem 2 months ago and I haven't changed anything with Outlook, Excel or my VBA code. I wonder if this is part of Microsoft slowly breaking the classic version of Outlook to drive user to the new, riddled-with-ads version of Outlook. Does anyone else have this problem?

Sub Win_Create_PDF_and_Email()

Call Create_Win_Form

Dim OutlookApp As Object

Dim OutlookMail As Object

' Create Outlook application object

Set OutlookApp = CreateObject("Outlook.Application")

Set OutlookMail = OutlookApp.CreateItem(0)

' Create email

With OutlookMail

.to = Range("Selected_Email_Address").Value

.Subject = Range("Win_Email_Subject").Value

.Body = Range("Win_Email_Body").Value

.Attachments.Add Range("Win_Form_Path_and_Filename").Value

.Display

End With

' Release objects

Set OutlookMail = Nothing

Set OutlookApp = Nothing

End Sub

submitted by /u/Ok_Fondant1079
[link] [comments]

Want to read more?

Check out the full article on the original site

View original article