ASP functions for sending mail using CDONTS

Source: Internet
Author: User
<%
' Last Updated by recon on 05/14/2001
' On Error Resume Next

' Send Mail on Win2K using the CDONTS component

' Send regular mail
SendMail "admin@ny.com", "iamchn@263.net", "Normal mail!", "Please check the attatchment!", 2, 0, "C:\Love.txt"

' Send an HTML message
Dim M_fso, M_TF
Dim m_strhtml

Set M_fso = Server.CreateObject ("Scripting. FileSystemObject ")
Set M_TF = M_fso. OpenTextFile ("C:\Mail.htm", 1)
m_strhtml = M_TF. ReadAll

' Write m_strhtml
Set M_TF = Nothing
Set M_fso = Nothing

SendMail "admin@ny.com", "iamchn@263.net", "HTML mail!", m_strhtml, 2, 1, Null

' Parameter description
' strfrom: Email from sender
' Strto: Recipient email
' Strsubject: The subject of the letter
' Strbody: Letter Text
' Lngimportance: The importance of letters
': 0-Low importance
': 0-Medium importance (default)
': 0-High importance
' Lngatype: Letter Format
': The message body is used as HTML for 1 o'clock (you can send HTML messages at this time)
' Strattach: Path to Attachment
Sub SendMail (Strfrom, Strto, Strsubject, Strbody, Lngimportance, Lngatype, Strattach)
Dim objmail

Set objmail = Server.CreateObject ("CDONTS. NEWMAIL ")
With objmail

. From = Strfrom
. to = Strto
. Subject = Strsubject
. BODY = Strbody
. Importance = Lngimportance

If Lngatype = 1 Then
. BodyFormat = 0
. MailFormat = 0
End If

If IsEmpty (Strattach) = False and IsNull (Strattach) = False Then
. Attachfile Strattach
End If

. Send
End With
Set objmail = Nothing
End Sub
%>



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.