Guest User

Untitled

a guest
Aug 14th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. Private Sub btnSendEmail_Click()
  2. Dim Mail As New Message
  3. Dim Config As Configuration
  4. Set Config = Mail.Configuration
  5.  
  6. Config(cdoSendUsingMethod) = cdoSendUsingPort
  7. Config(cdoSMTPServer) = "smtp.gmail.com"
  8. Config(cdoSMTPServerPort) = 25
  9. Config(cdoSMTPAuthenticate) = cdoBasic
  10. Config(cdoSMTPUseSSL) = True
  11. Config(cdoSendUserName) = "xxx"
  12. Config(cdoSendPassword) = "xxx"
  13. Config.Fields.Update
  14.  
  15. Mail.To = "xxx"
  16. Mail.From = Config(cdoSendUserName)
  17. Mail.Subject = "Email Subject"
  18. Mail.HTMLBody = "<h>myname1</h>"
  19. Mail.AddAttachment "C:\Users\Indika\Desktop\VBA¥img¥Range.bmp"
  20. Mail.HTMLBody = "<h>myname2</h>"
  21. Mail.AddAttachment "C:\Users\Indika\Desktop\VBA¥img¥Range.bmp"
  22. On Error Resume Next
  23.  
  24. Mail.Send
  25.  
  26. If Err.Number <> 0 Then
  27. MsgBox Err.Description, vbCritical, "There was an error"
  28. Exit Sub
  29. End If
  30.  
  31. MsgBox "Your email has been sent", vbInformation, "Sent"
  32. End Sub
Add Comment
Please, Sign In to add comment