Write a vbs script to send an email

Source: Internet
Author: User
Tags email account

The program that executes the vbs script file is under the System32 file.

The following vbs script code completes sending an email to chen@gmail.com with the kekec@qq.com account ".

1 namespace = "http://schemas.microsoft.com/cdo/configuration"
2 set email = Createobject ("CDO. Message ")
3 email. From = "chen@gmail.com" 'mail address
4 email. To = "kekec@qq.com" 'email address
5 email. Subject = "test _" + CSTR (now () 'Email Subject
6 email. textbody = "OK! It is only a test. "'mail content
7 email. addattachment "D: \ My Documents \ my pictures \ 809041233006998.jpg" 'attached
8 with email. configuration. Fields
9. Item (namespace & "sendusing") = 2 'cdo sending port number
10. Item (namespace & "smtpserver") = "smtp.gmail.com" 'smtp Server
11. Item (namespace & "smtpserverport") = 465 'smtp server port number
12. Item (namespace & "smtpusessl") = true 'whether the SMTP server uses SSL
13. Item (namespace & "smtpauthenticate") = 1' the authentication method is basic
14. Item (namespace & "sendusername") = "chen@gmail.com" 'sender email account
15. Item (namespace & "sendpassword") = "*************" 'sender's email password
16. Update
17 end
18 email. Send

 

 

Emails received:

PS: When "smtpserver" "smtpserverport" "smtpusessl" and other information are set incorrectly, the script will pop up an error dialog box to show that the email fails to be sent.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.