Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ' Save workbook
- Dim OutApp As Object
- Dim OutMail As Object
- Dim strbody1 As String
- Set OutApp = CreateObject("Outlook.Application")
- Set OutMail = OutApp.CreateItem(0)
- ' Save workbook
- ActiveWorkbook.SaveAs ("C:\Users\User1\Downloads\Billing Report " & Format(Now(), "YYYY-MM-DD") & ".xlsx")
- ‘change save path (this file name is “Billing report”
- ‘and is saved under Downloads)
- ' Email workbook
- Dim OutlookApp As Object
- Dim OutlookMail As Object
- Set OutlookApp = CreateObject("Outlook.Application")
- Set OutlookMail = OutlookApp.CreateItem(0)
- 'Let us create the email message and display it
- 'Make sure to change the parameters below
- With OutlookMail
- .To = "[email protected]"
- .Subject = Application.ActiveWorkbook.Name
- .Body = "Hi, latest billings report is attached."
- .Attachments.Add ActiveWorkbook.FullName
- .Send
- End With
- Set OutlookMail = Nothing
- Set OutlookApp = Nothing
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment