Guest User

Untitled

a guest
Dec 2nd, 2022
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | Source Code | 0 0
  1. ' Save workbook
  2.  
  3. Dim OutApp As Object
  4. Dim OutMail As Object
  5. Dim strbody1 As String
  6. Set OutApp = CreateObject("Outlook.Application")
  7. Set OutMail = OutApp.CreateItem(0)
  8.  
  9.  
  10. ' Save workbook
  11.  
  12. ActiveWorkbook.SaveAs ("C:\Users\User1\Downloads\Billing Report " & Format(Now(), "YYYY-MM-DD") & ".xlsx")
  13. ‘change save path (this file name is “Billing report”
  14. ‘and is saved under Downloads)
  15.  
  16.  
  17. ' Email workbook
  18.  
  19.  
  20. Dim OutlookApp As Object
  21. Dim OutlookMail As Object
  22. Set OutlookApp = CreateObject("Outlook.Application")
  23. Set OutlookMail = OutlookApp.CreateItem(0)
  24.  
  25. 'Let us create the email message and display it
  26. 'Make sure to change the parameters below
  27. With OutlookMail
  28. .Subject = Application.ActiveWorkbook.Name
  29. .Body = "Hi, latest billings report is attached."
  30. .Attachments.Add ActiveWorkbook.FullName
  31. .Send
  32. End With
  33.  
  34. Set OutlookMail = Nothing
  35. Set OutlookApp = Nothing
  36.  
  37. End Sub
  38.  
Advertisement
Add Comment
Please, Sign In to add comment