Guest User

Untitled

a guest
Nov 11th, 2017
503
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.03 KB | None | 0 0
  1. Dim CDOmsg As CDO.Message
  2. Set CDOmsg = New CDO.Message
  3.  
  4. With CDOmsg.Configuration.Fields
  5. .Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
  6. .Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
  7. .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
  8. .Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "myemail@gmail.com"
  9. .Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "mypass"
  10. .Item("http://schemas.microsoft.com/cdo/configuration/smptserverport") = 465
  11. .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 'NTLM method
  12. .Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
  13. .Update
  14. End With
  15. ' build email parts
  16. With CDOmsg
  17. .Subject = "the email subject"
  18. .From = "myemail@gmail.com"
  19. .To = "mailto@gmail.com"
  20. .CC = ""
  21. .BCC = ""
  22. .TextBody = "the full message body goes here. you may want to create a variable to hold the text"
  23. End With
  24. CDOmsg.Send
  25. Set CDOmsg = Nothing
  26.  
  27. Function email(ByVal sender_email As String, _
  28. ByVal email_message As String, _
  29. ByVal email_message2 As String, _
  30. ByVal reply_address As String, _
  31. ByVal sender_name As String)
  32.  
  33. Dim Mail As New Message
  34.  
  35. Dim Cfg As Configuration
  36.  
  37. Set Cfg = Mail.Configuration
  38.  
  39. 'SETUP MAIL CONFIGURATION FIELDS
  40. Cfg(cdoSendUsingMethod) = cdoSendUsingPort
  41. Cfg(cdoSMTPServer) = 'SMTP
  42. Cfg(cdoSMTPServerPort) = 'SMTPport
  43. Cfg(cdoSMTPAuthenticate) = cdoBasic
  44. Cfg(cdoSMTPUseSSL) = True
  45. Cfg(cdoSendUserName) = 'sender_email
  46. Cfg(cdoSendPassword) = 'password
  47. Cfg.Fields.Update
  48.  
  49. 'SEND EMAIL
  50. With Mail
  51. .From = 'sender_name & sender_email
  52. .ReplyTo = 'reply_address
  53. .To = 'receiver
  54. .CC = 'carbonCopy
  55. .BCC = 'blindCopy
  56. .Subject = 'SubjectLine
  57. .HTMLBody = 'email_message & email_message2
  58. .Attachments.Add attFilePath
  59. .Send
  60. End With
Add Comment
Please, Sign In to add comment