利用CDONTS发送邮件的ASP函数

 1   
 2'Last Updated By Recon On 05/14/2001   
 3'On Error Resume Next   
 4  
 5'利用CDONTS组件在Win2k上发送邮件   
 6  
 7'发送普通邮件   
 8SendMail "[email protected]", "[email protected]", "Normal Mail!", "Please check the attatchment!", 2, 0, "C:\Love.txt"   
 9  
10'发送HTML邮件   
11Dim m_fso, m_tf   
12Dim m_strHTML   
13  
14Set m_fso = Server.CreateObject("SCRIPTING.FILESYSTEMOBJECT")   
15Set m_tf = m_fso.OpenTextFile("C:\Mail.htm", 1)   
16m_strHTML = m_tf.ReadAll   
17  
18'Write m_strHTML   
19Set m_tf = Nothing   
20Set m_fso = Nothing   
21  
22SendMail "[email protected]", "[email protected]", "HTML Mail!", m_strHTML, 2, 1, Null   
23  
24'参数说明   
25'strFrom : 发件人Email   
26'strTo : 收件人Email   
27'strSubject : 信件主题   
28'strBody : 信件正文   
29'lngImportance : 信件重要性   
30' : 0 - 低重要性   
31' : 0 - 中等重要性(默认)   
32' : 0 - 高重要性   
33'lngAType : 信件格式   
34' : 为1时将邮件正文作为HTML(此时可以发送HTML邮件)   
35'strAttach : 附件的路径   
36Sub SendMail(strFrom, strTo, strSubject, strBody, lngImportance, lngAType, strAttach)   
37Dim objMail   
38  
39Set objMail = Server.CreateObject("CDONTS.NEWMAIL")   
40With objMail   
41  
42.From = strFrom   
43.To = strTo   
44.Subject = strSubject   
45.Body = strBody   
46.Importance = lngImportance   
47  
48If lngAType = 1 Then   
49.BodyFormat = 0   
50.MailFormat = 0   
51End If   
52  
53If IsEmpty(strAttach) = False And IsNull(strAttach) = False Then   
54.AttachFile strAttach   
55End If   
56  
57.Send   
58End With   
59Set objMail = Nothing   
60End Sub   
Published At
Categories with Web编程
Tagged with
comments powered by Disqus