Send Email VBA

lizemi

New Member
Joined
Sep 5, 2021
Messages
28
Office Version
  1. 365
Platform
  1. Windows
Good Day
I have the following code that emails a single sheet to a email in the sheet.
I noticed that it saves a copy of the sheet in pdf - I would like that but can not seem to find where to tell it to save the PDF file
currently it seems to save to my documents but I would like to have it saved to a SharePoint folder - So even if different users use it, it saves to the same folder.

Sub Send_Email()
Dim wPath As String, wFile As String

wPath = ThisWorkbook.Path
wFile = "Filepdf.pdf"
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=Range("d3"), _
Quality:=xlQualityStandard, IncludeDocProperties:=True, _
IgnorePrintAreas:=False, OpenAfterPublish:=False


Set dam = CreateObject("Outlook.Application").CreateItem(0)
'
dam.To = Range("b39")
dam.Subject = Range("d3")
dam.Body = "Regards"
dam.Attachments.Add wPath & wFile
dam.Send
MsgBox "Email sent"


End Sub
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Change in this line the path of your folder in sharepoint
VBA Code:
wPath = ThisWorkbook.Path

For example:
VBA Code:
wPath = "https://sites.company.com/sites/Shared%20Documents/"

🤗
 
Upvote 0
Solution

Forum statistics

Threads
1,224,816
Messages
6,181,139
Members
453,021
Latest member
Justyna P

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