willow1985
Well-known Member
- Joined
- Jul 24, 2019
- Messages
- 929
- Office Version
- 365
- Platform
- Windows
I have 2 codes, one that creates a pdf and the other that sends an email.
I merged them below but want to add 2 pdf attachments to the email: the one I just created and another located in the same directory.
(Note: if that file is not found, a msg stating this would be preferred just in case of error)
Attachments I want to add are located in the same path: Sheets("CI Form Open").Range("T1")
Name of #1 is in: T2.pdf
Name of #2 is in: N2.pdf
Any help would be greatly appreciated!
I merged them below but want to add 2 pdf attachments to the email: the one I just created and another located in the same directory.
(Note: if that file is not found, a msg stating this would be preferred just in case of error)
Attachments I want to add are located in the same path: Sheets("CI Form Open").Range("T1")
Name of #1 is in: T2.pdf
Name of #2 is in: N2.pdf
Any help would be greatly appreciated!
VBA Code:
Sub SavePDF_send mail()
'
' SavePDF_send mail Macro
'
Dim Path As String
Dim filename As String
Path = Sheets("CI Form Open").Range("T1")
filename = Sheets("CI Form Open").Range("T2")
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, filename:=Path & filename & ".pdf", Quality:=xlQualityStandard, _
IncludeDocProperties:=False, IgnorePrintAreas:=False, OpenAfterPublish:=True
Dim OutlookApp As Object, MItem As Object
Set OutlookApp = CreateObject("Outlook.Application")
Set MItem = OutlookApp.CreateItem(0)
With MItem
.to = Sheets("CI Form Open").Range("T3")
.Subject = Sheets("CI Form Open").Range("N2")
.Body = "[This is an Automated Message - Do not reply]" & vbCrLf & "Continuous Improvement Database"
.Display
.Send
End With
MsgBox "E-mail Sent"
Case vbNo
GoTo Quit:
End Select
Quit: