In ASP Program Many emails are sent using jmail, mainly because most virtual hosts support it, while others support less.
The following is an example of jmail mail. Code :
If you try it on your machine, download jmail. dll, download and unzip it, and double-click setup. BAT to complete the installation!
Copy code The Code is as follows: <%
On Error resume next
Dim jmail, contentid
Set jmail = server. Createobject ("jmail. Message ")
Jmail. charset = "gb2312" ''' character set, "US-ASCII" by default"
'''Jmail. isoencodeheaders = false''' indicates whether to perform ISO encoding. The default value is true.
''' Sender information (Value assignment using variables)
Jmail. From = "xiaoz@xiaoz.com" ''' sender address
Jmail. fromname = "xiaoz. com" ''' sender name
Jmail. Subject = "subject" ''' subject
''' Authentication
Jmail. mailserverusername = "myusername" ''' user name for authentication
Jmail. mailserverpassword = "mypassword" ''' authentication Password
''' Sets the priority from 1 to 5. The higher the priority, the higher the 3 is normal.
Jmail. Priority = 3
Jmail. addheader "originating-IP", request. servervariables ("remote_addr ")
''' Add a recipient. Variable Email: Recipient address. Multiple recipients can be added in the same statement.
Jmail. addrecipient ("xiaoz@xiaoz.com ")
''' Add the attachment. The variable filename is the absolute address of the attachment file. Make sure that the IUSR _ machine name has the permission to access the file]
''' [Whether the parameter is set to (true) or not (false) as the inline method]
''' Contentid = jmail. addattachment (server. mappath ("jmail. asp"), true)
''' Subject (HTML (note the attachment Link Method in the letter ))
Jmail. htmlbody = "<HTML>
''' Subject (text part)
Jmail. Body = "our emails are in HTML format, but your email viewing software may not support it... Body, body, body"
''' Send [Call format: objjmail. Send ([Username: password @] smtpserveraddress [: Port])]
Jmail. Send ("smtp.163.com ")
''' Close and clear the object
Jmail. Close ()
Set jmail = nothing
If err. Number <> 0 then
response. Write "failed to send! "
else
response. write" the email is sent successfully! "
end if
%>