• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

macro to send pdf file in outlook

webmax

Member
Hi,

I have PDF Files in the folder for examples (forms) if i click the button in the excel index which i link the pdf files it automatically open the pdf file and go to the outlook after i sends the mail the PDF should automatically close.
 
Code:
Sub SMC()

'Create an Outlook object and new mail message 
Set oApp = GetObject(,"Outlook.Application")'You must ensure that Outlook is open and logged in
 Set oMail = oApp.CreateItem(0) 
'Set mail attributes (uncomment lines to enter attributes) 
' In this example, only the attachment is being added to the mail message
 With oMail 
    .To = "XYZ@XYZ.COM" 
    .CC = ActiveWorkbook.Worksheets("MailList").Range("A1").Value 
    .Subject = "Your PDF Attached" 
    .body = "Dear XX," & vbCrLf & vbCrLf & _ 
    "I have reviewed your PDF it looks great." & vbCrLf & vbCrLf & _ 
    "Please see attached for my comments and respond ASAP." & vbCrLf & vbCrLf & _ 
    "Kind regards," 
    .Attachments.Add ActiveWorkbook.Worksheets("MailList").Range("B1").Value 
    .Display
 End With

End Sub
 
Hi sam,
I dont want the mail id to place in the file. If i click the button (Excel) it automatically open the outlook and attached the particular PDF file in the oulook that after that i tmanually ype the email id , Subject & body of the letter.
 
Hi webmax,

Please change the TO email ID in code to blank ("").

Code:
.To = "XYZ@XYZ.COM
 
'Change above line to
 
.To = ""

When mail appears with attachment, you can manually input the mail ID.

Thanks,
Mahesh
 
Back
Top