Vba pdf export macro email

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?

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
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.

Forum statistics

Threads
1,223,275
Messages
6,171,119
Members
452,381
Latest member
Nova88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top