[Import] Use CDO. Message + SMTP to send emails

Source: Internet
Author: User

<%
Const cdoSendUsingMethod = "http://schemas.microsoft.com/cdo/configuration/sendusing"
Const cdoSendUsingPort = 2
Const cdoSMTPServer = "http://schemas.microsoft.com/cdo/configuration/smtpserver"
Const cdoSMTPServerPort = "http://schemas.microsoft.com/cdo/configuration/smtpserverport"
Const cdoSMTPConnectionTimeout = "http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout"
Const cdoSMTPAuthenticate = "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"
Const cdoBasic = 1
Const cdoSendUserName = "http://schemas.microsoft.com/cdo/configuration/sendusername"
Const cdoSendPassword = "http://schemas.microsoft.com/cdo/configuration/sendpassword"

Dim oCDOConfig 'as CDO. Configuration
Dim ocdomessage' As CDO. Message
Dim Fields 'As ADODB. Fields

Set oCDOConfig = Server. CreateObject ("CDO. Configuration ")
Set Fields = oCDOConfig. Fields

With Fields
. Item (cdoSendUsingMethod) = cdoSendUsingPort
. Item (cdoSMTPServer) = "SMTP server" '// change to an available external email server Domain Name
. Item (cdoSMTPServerPort) = 25
. Item (cdoSMTPConnectionTimeout) = 10
. Item (cdoSMTPAuthenticate) = cdoBasic
. Item (cdoSendUserName) = "SMTP username" '// The username of the above server
. Item (cdoSendPassword) = "SMTP password" '// Password
. Update
End

Set oCDOMessage = Server. CreateObject ("CDO. Message ")
Set oCDOMessage. Configuration = oCDOConfig

With oCDOMessage
. From = Trim ("sender email address") '// the sender's email address
. To = Trim ("recipient email address") '// recipient's email address
. Subject = Trim ("mail title") '// mail title
. Cc = Trim ("Cc address") '// Cc address
. Bcc = Trim ("encrypted CC address") '// encrypted CC
. Bodypart. Charset = "UTF-8" '// Encoding
. TextBody = Trim ("body") '// text body
. HTMLBody = Trim (". CreateMHTMLBody "reads an HTML page as the mail body" '// available direct path/remote path/relative path
. AddAttachment "C: \ WINDOWS \ explorer. scf" '// email attachment
. Send
End

Set Fields = Nothing
Set oCDOMessage = Nothing
Set oCDOConfig = Nothing
%>

Source: http://Jorkin.Reallydo.Com/default.asp? Id = 491

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.