ASP uses the jmail4.3 module

Source: Internet
Author: User
Tags mail split trim
Jmail|jmail often use the JMail component in the Web site to send mail. Simply put the commonly used functions as a module for easy invocation.

Put the program in a file and then include the call. (JMAIL4.3)

<% ' Warning function
Sub W_msg (Message,w_to,w_link)
' Message is the warning you want to eject, w_to=1 means to automatically back a page, when the w_to<>1 W_link represents the page to jump
If w_to= "1" Then
%>
<script language= "JavaScript" >
<!--
function Index () {window.alert (' <%=message%> '); History.back (-1)}
Index ();
-->
</script>
<%else%>
<script language= "JavaScript" >
<!--
function Index () {window.alert (' <%=message%> '); window.location= "<%=w_link%>"}
Index ();
-->
</script>
<%end if
End Sub%>
<%
Sub SendMail (Mailtitle,mailtext,mailaddress,mailcc,mailbcc,attachment,mailserver)
If mailtitle= "" Then
mailtitle= "System Test Mail"
End If
If mailtext= "" Then
mailtext= "Just a Test"
End If
If mailaddress= "" Then
Call W_msg ("mail address cannot be empty", "1", "")
End If
If mailserver= "" Then
Mailserver= "Smtp.163.com"
End If
Set Msg=server.createobject ("Jmail.message")
Msg.silent = True
Msg.logging = True
Msg. charset= "GB2312"
Msg. ContentType = "Text/html"
Msg. Mailserverusername= "YourUserName"
Msg. Mailserverpassword= "YourPassword"
Msg. From= "Youremail"
Msg. Fromname= "Dorryyang"
Mailaddress_s=split (MailAddress, ",") ' e-mail address used, lattice open
For i=0 to UBound (mailaddress_s)
Msg. AddRecipient Trim (mailaddress_s (i))
Next
If mailcc<> "" Then
Mailcc_s=split (MAILCC, ",")
For i=0 to UBound (mailcc_s)
Msg. ADDRECIPIENTCC Trim (mailcc_s (i))
Next
End If
If mailbcc<> "" Then
Mailbcc_s=split (MAILBCC, ",")
For i=0 to UBound (mailbcc_s)
Msg. ADDRECIPIENTBCC Trim (mailbcc_s (i))
Next
End If
If attachment<> "" Then
Msg. AddAttachment (attachment) ' Attachment write attachment address
End If
Msg. Subject=mailtitle
Msg. Htmlbody=mailtext
Msg. Send (MailServer)
Msg.close
Set msg=nothing
Call W_msg ("Send Success", "1", "")
End Sub
%>




Related Article

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.