Youseepooo
New Member
- Joined
- Feb 5, 2019
- Messages
- 37
hello
this code works great but i would like to make the attached file in the email named the same way it is saved. im not sure how to do it can someone help?
currently in the email the attached pdf is called " Desktop Daily Look Ahead.pdf" but i want it to say " Daily look ahead for " & (tomorrows date )
thanks to anyone who can help me
this code works great but i would like to make the attached file in the email named the same way it is saved. im not sure how to do it can someone help?
Code:
Sub Send_Email()
Dim dam As Object
Dim wPath As String
Dim wFile As String
Dim x As Date
Dim strPathToImageFolder As String
Dim strImageFilename As String
Dim strHTML As String
x = Format(Now() + 1, "MMMM dd, yyyy")
wPath = ThisWorkbook.Path
[COLOR=#ff0000] wFile = "Daily Look Ahead.pdf"[/COLOR]
ActiveSheet.Range("B1:I47").ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"J:\Schedules\PCC Daily Schedule\2019 March\" & Format(Now() + 1, "MMMM dd, yyyy") & ".pdf", Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, _
OpenAfterPublish:=False
strPathToImageFolder = "C:\Users\ymussa\Pictures\Camera Roll"
If Right(strPathToImageFolder, 1) <> "\" Then
strPathToImageFolder = strPathToImageFolder & "\"
End If
strImageFilename = "pcc.jpg"
strHTML = "<p>Hello all,</p>"
strHTML = strHTML & "<p>The Daily Look Ahead Schedule for " & x & " is attached.</p>"
strHTML = strHTML & "<p>Thank You<br>Yousef Mussa<br>Assistant Engineer<br><img src=""cid:" & strImageFilename & """><br><br>Sent with VBA</p>"
Set dam = CreateObject("Outlook.Application").CreateItem(0)
With dam
.To = "ymussa@perfettocontracting.com"
'.cc = "jsilko@perfettocontracting.com"
.Subject = "Daily Schedule for " & x
.attachments.Add wPath & wFile
.attachments.Add strPathToImageFolder & strImageFilename
.htmlbody = strHTML
.Send
End With
Set dam = Nothing
MsgBox "Email sent"
End Sub
currently in the email the attached pdf is called " Desktop Daily Look Ahead.pdf" but i want it to say " Daily look ahead for " & (tomorrows date )
thanks to anyone who can help me