Advertisement
priore

Send an email with GMail account and CDO Components

Apr 28th, 2012
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
ASP 2.09 KB | None | 0 0
  1. '
  2. '  Created by Danilo Priore.
  3. '  Copyright (c) 2012 Prioregroup.com. All rights reserved.
  4. '
  5. '
  6. '  Permission is hereby granted, free of charge, to any person obtaining a copy
  7. '  of this software and associated documentation files (the "Software"), to deal
  8. '  in the Software without restriction, including without limitation the rights
  9. '  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  10. '  copies of the Software, and to permit persons to whom the Software is
  11. '  furnished to do so, subject to the following conditions:
  12. '
  13. '  The above copyright notice and this permission notice shall be included in
  14. '  all copies or substantial portions of the Software.
  15. '
  16. '  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. '  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18. '  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  19. '  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20. '  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  21. '  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  22. '  THE SOFTWARE.
  23. '
  24. '
  25.  
  26. Dim iMsg, iConf, Flds
  27.  
  28. Set iMsg = CreateObject("CDO.Message")
  29. Set iConf = CreateObject("CDO.Configuration")
  30. Set Flds = iConf.Fields
  31.  
  32. ' send one copy with Google SMTP server (with autentication)
  33. schema = "http://schemas.microsoft.com/cdo/configuration/"
  34. Flds.Item(schema & "sendusing") = 2
  35. Flds.Item(schema & "smtpserver") = "smtp.gmail.com"
  36. Flds.Item(schema & "smtpserverport") = 465
  37. Flds.Item(schema & "smtpauthenticate") = 1
  38. Flds.Item(schema & "sendusername") = "mymail@gmail.com"
  39. Flds.Item(schema & "sendpassword") =  "mypassword"
  40. Flds.Item(schema & "smtpusessl") = 1
  41. Flds.Update
  42.  
  43. With iMsg
  44. .To = emailaddr
  45. .From = "Myname <myemail@mydomain.com>"
  46. .Subject = "Test send with gmail account"
  47. .HTMLBody = message
  48. .Sender = "Myname"
  49. .Organization = "Myname"
  50. .ReplyTo = "myemail@mydomain.com"
  51. Set .Configuration = iConf
  52. SendEmailGmail = .Send
  53. End With
  54.  
  55. set iMsg = nothing
  56. set iConf = nothing
  57. set Flds = nothing
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement