JediMindTricks
New Member
- Joined
- Jun 17, 2015
- Messages
- 16
Hey guys, I have a macro that's been working perfectly for years which would create an email for each invoice on each separate sheet, to an email address listed in a cell on each page, while at the same time creating a pdf of the individual excel page and attaching it to the email. The emails would be sent from my primary outlook account, which was a gmail account at the time. Worked great until I installed an exchange account on outlook, which "took over" outlook as my default send mail account.
The current excel macro is this:
Sub Send()
Dim fName As String, i As Integer, Mail_Object, o As Variant, ws As Worksheet
For Each ws In Worksheets
If ws.Name <> "Name of Excluded Sheet 1" And ws.Name <> "Name of Excluded Sheet 2" And ws.Name <> "Name of Excluded Sheet 3" Then
ws.Activate
With ActiveSheet
fpath = "C:\temp"
fName = .Range("A2").Value
.ExportAsFixedFormat Type:=xlTypePDF, Filename:=fpath & fName, Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
End With
Set Mail_Object = CreateObject("Outlook.Application")
With Mail_Object.CreateItem(o)
.Subject = "Subject Heading for Email" ' CHANGE TO SUIT
.To = Range("B2").Value 'CHANGE TO SUIT
.Body = "Comments in the body of the Email" 'change comments to suit
.Attachments.Add fpath & fName & ".PDF"
'.Send
.display
End With
End If
Next ws
End Sub
The macro will only send from the exchange account. I would like the macro to send from my gmail.com account, which is no longer the default mail account in Outlook (and I can't make it as such).
Does anyone have any idea how to modify my current macro to send from a non-default account in Outlook? Any help appreciated!
Thanks for any suggestions. My experience is extremely limited (almost none) and I am looking for help.
The current excel macro is this:
Sub Send()
Dim fName As String, i As Integer, Mail_Object, o As Variant, ws As Worksheet
For Each ws In Worksheets
If ws.Name <> "Name of Excluded Sheet 1" And ws.Name <> "Name of Excluded Sheet 2" And ws.Name <> "Name of Excluded Sheet 3" Then
ws.Activate
With ActiveSheet
fpath = "C:\temp"
fName = .Range("A2").Value
.ExportAsFixedFormat Type:=xlTypePDF, Filename:=fpath & fName, Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
End With
Set Mail_Object = CreateObject("Outlook.Application")
With Mail_Object.CreateItem(o)
.Subject = "Subject Heading for Email" ' CHANGE TO SUIT
.To = Range("B2").Value 'CHANGE TO SUIT
.Body = "Comments in the body of the Email" 'change comments to suit
.Attachments.Add fpath & fName & ".PDF"
'.Send
.display
End With
End If
Next ws
End Sub
The macro will only send from the exchange account. I would like the macro to send from my gmail.com account, which is no longer the default mail account in Outlook (and I can't make it as such).
Does anyone have any idea how to modify my current macro to send from a non-default account in Outlook? Any help appreciated!
Thanks for any suggestions. My experience is extremely limited (almost none) and I am looking for help.