Guest User

Untitled

a guest
May 29th, 2016
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. Set fso=CreateObject("Scripting.FileSystemObject")
  2. strSMTP="smtp.gmail.com"
  3. strSubject="mail@gmail.com"
  4. strSubject2="Attachment file"
  5. strBody="-"
  6. strAttach="FILEPATH"
  7. If fso.FileExists(strAttach) then
  8. Set iMsg = CreateObject("CDO.Message")
  9. Set iConf = CreateObject("CDO.Configuration")
  10. iConf.Load -1 ' CDO Source Defaults
  11. Set Flds = iConf.Fields
  12. With Flds
  13. .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
  14. .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = strSMTP
  15. .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
  16. .Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
  17. .Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "mail@gmail.com"
  18. .Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "password"
  19. .Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = 1
  20. .Update
  21. End With
  22. With iMsg
  23. Set .Configuration = iConf
  24. .To = "mail2@gmail.com"
  25. .CC = ""
  26. .BCC = ""
  27. .From = "mail1@gmail.com"
  28. .Subject = strAttach
  29. .TextBody = strBody
  30. .AddAttachment strAttach
  31. .Send
  32. End With
  33. Set iMsg = Nothing
  34. Set iConf = Nothing
  35. Else
  36. MsgBox "The specified attachment does not exist"
  37. End if
Add Comment
Please, Sign In to add comment