Friends who have used foreign servers, especially those who use the Godaddy host, must be familiar with this email sending component. Here we will provide you with a detailed usage:
<%
'Last updated by recon on 05/14/2001
'On error resume next
'Use the cdonts component to send emails on Win2k
Dim objmail
'Normal mail
'No subject
Set objmail = server. Createobject ("cdonts. newmail ")
Objmail. From = "iamchn@263.net"
Objmail. To = "iamchn@21cn.com"
Objmail. Subject = "test1"
Objmail. Send
Set objmail = nothing
'Normal mail
'Subject
Set objmail = server. Createobject ("cdonts. newmail ")
Objmail. From = "iamchn@263.net"
Objmail. To = "iamchn@21cn.com"
Objmail. Subject = "Test2"
Objmail. Body = "when I was young, I listened to the radio ..."
Objmail. Send
Set objmail = nothing
'Normal mail
'There are multiple deliveries. There are subjects
Set objmail = server. Createobject ("cdonts. newmail ")
Objmail. From = "iamchn@263.net"
Objmail. To = "iamchn@21cn.com; iamchn@263.net"
Objmail. Subject = "test3"
Objmail. Body = "when I was young, I listened to the radio ..."
Objmail. Send
Set objmail = nothing
'Normal mail
'Cc. Subject. Important
Set objmail = server. Createobject ("cdonts. newmail ")
Objmail. From = "iamchn@263.net"
Objmail. To = "iamchn@21cn.com"
Objmail. Cc = "iamchn@263.net; recon_chan@sohu.com"
Objmail. Subject = "test4"
Objmail. Body = "when I was young, I listened to the radio ..."
Objmail. Importance = 2
Objmail. Send
Set objmail = nothing
'Normal mail
'Cc. bcc. Subject. Importance
Set objmail = server. Createobject ("cdonts. newmail ")
Objmail. From = "iamchn@263.net"
Objmail. To = "iamchn@21cn.com"
Objmail. Cc = "recon_chan@sohu.com"
Objmail. bcc = "iamchn@263.net; recon_chan@sina.com"
Objmail. Subject = "test5"
Objmail. Body = "when I was young, I listened to the radio ..."
Objmail. Importance = 2
Objmail. Send
Set objmail = nothing
'Normal mail
'Subject. Important. include attachments
Set objmail = server. Createobject ("cdonts. newmail ")
Objmail. From = "iamchn@263.net"
Objmail. To = "iamchn@21cn.com"
Objmail. Subject = "test6"
Objmail. Body = "when I was young, I listened to the radio ..."
Objmail. Importance = 2
Objmail. attachfile "C: \ love.txt"
Objmail. Send
Set objmail = nothing
'Html mail
'Subject. Important
'Note: the use of attachurl may be incorrect.
Dim FSO, TF
Dim strhtml
Set FSO = server. Createobject ("scripting. FileSystemObject ")
Set TF = FSO. opentextfile ("C: \ mail.htm", 1)
Strhtml = TF. readall
Write strhtml
Set TF = nothing
Set FSO = nothing
Set objmail = server. Createobject ("cdonts. newmail ")
Objmail. From = "iamchn@263.net"
Objmail. To = "iamchn@21cn.com"
Objmail. Subject = "test7"
Objmail. Body = strhtml
Objmail. bodyformat = 0
Objmail. mailformat = 0
Objmail. Importance = 2
Objmail. attachurl "C: \ common.css", "common.css"
Objmail. attachurl "C: \ logo.gif", "logo.gif"
Objmail. Send
Set objmail = nothing
%>
////////////////
A process. In addition, cdonts can be used under iis5. You must configure your SMTP service in the Internet manager.
<%
Sub Sendmail (fromwho, towho, subject, body)
Dim CDO
Set CDO = server. Createobject ("cdonts. newmail ")
CDO. From = fromwho
CDO. To = towho
CDO. Subject = subject
CDO. Body = body
CDO. mailformat = 0
The description is sent by mime.
CDO. bodyformat = 0
'Can contain HTMLCode
CDO. Importance = 0
'Mail priority level 0-1-2
'Cdo. Cc = xx@xx.net CC
& Apos; CDO. bcc = xx@sf.net BCC
'Cdo. attachfile "" attachment
CDO. Send
Set CDO = nothing
End sub
Sub sendattachmail (fromwho, towho, subject, body, attachfile)
Dim CDO
Set CDO = server. Createobject ("cdonts. newmail ")
CDO. From = fromwho
CDO. To = towho
CDO. Subject = subject
CDO. Body = body
CDO. mailformat = 0
CDO. bodyformat = 0
CDO. Importance = 0
CDO. attachfile
CDO. Send
Set CDO = nothing
End sub
%>
Sending HTML-format email routines with attachments
How can I use ASP to send emails with attachments in HTML format? The following provides a routine.
<% @ Language = VBScript %>
<%
Response. Buffer = true
Response. expires = 0
'Create an object instance
Set mymail = server. Createobject ("cdonts. newmail ")
'Below is the content to be sent
Html = "<HTML>"
Html = HTML & "Html = HTML & "<title> sending cdonts email using HTML </title>"
Html = HTML & "Html = HTML & "<body bgcolor =" "ffffff" ">"
Html = HTML & "<p> <font size = 7>"
Html = HTML & "this is a test mail in HTML <br>"
Html = HTML & "Mail content here... </font> </P>"
Html = HTML & "</body>"
Html = HTML & "
'Sender
Mymail. From = "somebody@somewhere.com"
'Recipient
Mymail. To = "nobody@somewhere.com"
'Bcc CC
Mymail. bcc = "nobody@somewhere.com"
'CC
Mymail. Cc = "nobody@somewhere.com"
'Mail importance
'0 low importance
'1 importance (default)
'2 high importance
Mymail. Importance = 2
'Subject
Mymail. Subject = "test mail in HTML"
'Attachment (note e: \ test.txt refers to the location on the server. If you use a relative path, you must use server. mappath to map to a real path)
Mymail. attachfile "E: \ test.txt"
'Newmail object text format
'0' indicates that the body can contain Hypertext Markup Language (HTML)
'1 indicates that the body is only used for plain text (default)
Mymail. bodyformat = 0
'Newmail object Encoding
'0' indicates that the MIME format is used.
'1 indicates that continuous plain text will be used (default value)
Mymail. mailformat = 0
'Assign a value to the text of the email object
Mymail. Body = html
'Send the email
Mymail. Send
'Destroy the object instance and release the memory.
Set mymail = nothing
%>
Use cdonts to send emails
--------------------------------------------------------------------
<%
Dim CDO
Set CDO = server. Createobject ("cdonts. newmail ")
CDO. From = fromwho "sender's mailbox
CDO. To = towho "recipient's mailbox
CDO. Subject = subject "topic
CDO. Body = body "email body
CDO. mailformat = 0 "indicates that the message is sent by mime.
CDO. bodyformat = 0 "can contain HTML code
CDO. Importance = 0 "mail priority level 0-1-2
CDO. Cc = xx@xx.net "CC
CDO. bcc = xx@sf.net "BCC
CDO. attachfile "attachment
CDO. Send
Set CDO = nothing
%>
Auto: http://blog.sina.com.cn/s/blog_5017a4f00100hdau.html
Exam:
Http://www.wowbox.com.tw/blog/article.asp? Id = 2277
Http://msdn.microsoft.com/en-us/library/ms526367 (exchg.10). aspx