Send mail using CDO.MESSAGE+SMTP

Source: Internet
Author: User
Tags mail trim domain name
smtp| Send mail <!--send code-->


<%


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 objconfig ' as CDO. Configuration


Dim objmessage ' as CDO. Message


Dim Fields ' as ADODB. Fields





Set objconfig = Server.CreateObject ("CDO.") Configuration ")


Set Fields = Objconfig.fields





with Fields


. Item (Cdosendusingmethod) = cdoSendUsingPort


. Item (Cdosmtpserver) = "SMTP Server" is changed to the available external mail server domain name


. Item (cdosmtpserverport) = 25


. Item (cdosmtpconnectiontimeout) = 10


. Item (cdosmtpauthenticate) = Cdobasic


. Item (cdosendusername) = user name of the server above "user name"


. Item (Cdosendpassword) = "Password" password


. Update


End With





Set objmessage = Server.CreateObject ("CDO.") Message ")


Set objmessage.configuration = objconfig





with Objmessage


. to = Trim (Request.Form ("M_user")) ' changed to the recipient's mail address


. from = "The sender's address (to be identical to the mail system above)" is changed to the sender's e-mail address


. Subject = Trim (Request.Form ("M_zhuzi")) ' title


. TextBody = Trim (Request.Form ("M_neirong")) ' Body


'. AddAttachment "C:\Scripts\Output.txt" Mail attachment


. Send


End With





Set Fields = Nothing


Set objmessage = Nothing


Set objconfig = Nothing


%>


<!--send code-->





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.