ASP 2 functions for sending e-Mail Online (using JMail and NewMail components)

Source: Internet
Author: User
Tags character set mail
Jmail|mail Components | functions | Online <% ' by Dicky qq:25941
Function JMail (Send_from,send_to,send_subject,send_body)
' Invoke the JMail component
' Send e-mail function
' Parameters:
' send_from-sent to the mailbox
' send_to-recipient's mailbox
' send_subject-Email Topic
' Send_body-Email content
Dim JMail
Set JMail = Server.CreateObject ("Jmail.message")

Jmail.charset = "gb2312" message character set, default to "Us-ascii"
' Jmail.isoencodeheaders = False ' is ISO-encoded, default to True

' Sender information (available in variable mode assignment)
Jmail.from = Send_from ' sender's mailbox
Jmail.fromname = "Administrator" sender name
Jmail.subject = Send_subject ' message subject

' Authentication
' Jmail.mailserverusername = ' user ' authenticated username
' Jmail.mailserverpassword = ' password ' authenticated password

' Set priority, range from 1 to 5, higher priority, 3 normal
Jmail.priority = 3

Jmail.addheader "Originating-ip", Request.ServerVariables ("REMOTE_ADDR")

' Add a recipient ' variable Send_from: Recipient address ' can be repeated by adding multiple
Jmail.addrecipient (Send_from)

' Message body (HTML (note how attachments are linked within a letter)
Jmail.htmlbody = Ubbcode (send_body)
Jmail.body = HtmlDecode (Ubbcode (send_body))

' Send ' call format: Objjmail.send ([username:password@]smtpserveraddress[:P ort])
' Jmail.send ("user:password@smtp.21cn.com")
Sendinfo=jmail.send (send_to)

' Close and clear the object
Jmail.close ()
Set JMail = Nothing
End Function

Function Send_mail (Send_from,send_to,send_subject,send_body)
' Call Windows Self-newmail component
' Send e-mail function
' Parameters:
' send_from-sent to the mailbox
' send_to-recipient's mailbox
' send_subject-Email Topic
' Send_body-Email content
Dim Mailobject
Set mailobject = Server.CreateObject ("CDONTS. NewMail ")
Mailobject.bodyformat = 0
Mailobject.mailformat = 0
Mailobject.from = Send_from
Mailobject.to = send_to
Mailobject.subject = Send_subject
Mailobject.body = Send_body
Mailobject.send ()
Set Mailobject = Nothing

If ERR Then
Response.Write "<script Language=javascript>alert (' Error:" & Err.Number & Err.Description & "Sorry, The email was sent to fail! : (');</script> "
Else
Response.Write "<script Language=javascript>alert" (' Congratulations, email sent success! ^_^ ');</script> "
End If
End Function%>




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.