ASP instance: Implement mail to send common attachments and embedded attachments

Source: Internet
Author: User
Tags format character set error code implement mail

There are many examples on the internet that jmail send emails without writing an attachment, or how to send an inline attachment (such as embedding an attachment picture inside an HTML letter).

When you're depressed, you finally "get out", OH yeah~~!!!

In fact, the most important thing is to comment out

' Jmail.contenttype = ' text/html '

(Why do you want to send an inline attachment picture?) Because if it is an IMG src= online address, in Outlook and other clients will show an ugly "X", you need to manually download the picture)

This example refers to the Dimac (W3jmail official) sample, file address:

C:\Program files\dimac\w3jmail4\examples\asp\htmlimage.asp

(All of the JMail are installed)

Example code:

<%
Set JMail = Server.CreateObject ("Jmail.message")
' Whether to encode the letterhead into the iso-8859-1 character set. The default is True
Jmail.isoencodeheaders = True
' If Jmail.silent is set to True,errorcode contains an error code
Jmail.silent = True
' Set the title and content encoding, if the title has Chinese, you must set the encoding to gb2312
Jmail.charset = "gb2312"
' Jmail.contenttype = ' text/html ' If an inline attachment must be commented out this line, important!
Jmail.from = "web@mail.skyhe.com" ' Sender address
Jmail.fromname = "skyhe System" ' Sender name
Jmail.mailserverusername = "Web" Authenticated user name
Jmail.mailserverpassword = "123456" Authenticated password
' Add a new recipient
Jmail.addrecipient "kittow@mail.skyhe.com", "Mr.example"
' JMAIL.ADDRECIPIENTBCC email ' confidential recipient's address
Address of CC of ' JMAIL.ADDRECIPIENTCC email '
Jmail.subject = "Picture Test!!! "
Jmail.body = "A nice picture if you can read html-mail."

' Add an ordinary attachment
Jmail.addattachment (Server.MapPath ("Images/email.gif"))
' Add an embedded attachment
' The return value of AddAttachment is used as a
' Reference to the ' image in the HTMLBody.
' ContentID = jmail.addattachment (Server.MapPath ("Images/email.gif"))
Dim ContentID
ContentID = Jmail.addattachment ("E:\images\email.gif")

' Only HTML format supports embedding picture attachments, we use HTML-formatted message content
' As only HTML formatted emails can contain inline images
' We use HTMLBody and appendhtml
Jmail.htmlbody = "jmail.appendhtml " "
Jmail.appendhtml "<br><br> good one huh?</body>
' If the mailbox does not support HTML format mail, we still need to give him a friendly hint
' But as not all mailreaders are capable of showing HTML emails
' We'll also add a standard text body
Jmail.body = "Too bad for You can ' t read html-mail."
Jmail.appendtext "There would have been a nice to you"

Jmail.send ("mail.skyhe.com")
Jmail.close ()
Set JMail = Nothing
%>



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.