ASP uses jmail to send Common attachments and embedded attachments (refer to the official w3jmail routine)

Source: Internet
Author: User
The call is done. It took several days to complete.> _ <
Many examples of jmail sending emails on the Internet do not show how to send attachments, or do not specify how to send embedded attachments (such as embedding attachments into HTML letters)
When I was so depressed, I finally went to the "Dark flowers". Oh, Yeah ~~!!!
In fact, the most important thing is to comment out this sentence.
'Jmail. contenttype = "text/html"

(Why do I need to send embedded attachment images? Because if it is an IMG src = address on the internet, it will be displayed as "X" in outlook and other clients, and you need to manually download the image)

This example refers to the sample of dimac (w3jmail official). The file address is as follows:
C: \ Program Files \ dimac \ w3jmail4 \ examples \ ASP \ htmlimage. asp
(Jmail has been installed)

Sample Code:
<%
'*************************************** **********
'**
'* Produced by skyhe. com *
'**
'* Code written by kittow at 2005-11 *
'* Http://www.skyhe.com *
'* Mail: kittow_at_263.net *
'**
'**
'*************************************** **********

Set jmail = server. Createobject ("jmail. Message ")
'Whether to encode the header into the iso-8859-1 character set. The default is true
Jmail. isoencodeheaders = true
'If jmail. Silent is set to true, errorcode contains the error code
Jmail. Silent = true
'Set the title and content encoding. If the title has Chinese characters, you must set the encoding to gb2312.
Jmail. charset = "gb2312"
'Jmail. contenttype = "text/html" 'it is important to comment out this line if an embedded attachment is sent!
Jmail. From = "web@mail.skyhe.com" 'sender address
Jmail. fromname = "skyhe System" 'sender name
Jmail. mailserverusername = "Web" 'user name for authentication
Jmail. mailserverpassword = "123456" 'authentication Password
'Add a new recipient
Jmail. addrecipient "kittow@mail.skyhe.com", "mr. Example"
'Jmail. addrecipientbcc email 'address of the BCC recipient
'Jmail. addrecipientcc email 'address of the email CC recipient
Jmail. Subject = "image test !!! "
Jmail. Body = "a nice picture if you can read HTML-mail ."

'Add a common attachment.
Jmail. addattachment (server. mappath ("images/email.gif "))
'Add an embedded attachment.
'The return value of addattachment is used as
'Reference to the image in the htmlbody.
'Contentid = jmail. addattachment (server. mappath ("images/email.gif "))
Dim contentid
Contentid = jmail. addattachment ("E: \ images \ email.gif ")

'The only HTML format supports embedding image attachments. We use HTML format for mail content.
'As only HTML formatted emails can contain Inline images
'We use htmlbody and appendhtml
Jmail. htmlbody = "<HTML> <body> <font color =" red "> Hi, here is a nice picture: </font> <br>"
Jmail. appendhtml "Jmail. appendhtml "<br> good one huh? </Body>
'If the recipient's mailbox does not support HTML emails, we still need to give him a friendly prompt.
'But as not all mailreaders are capable of showing HTML emails
'We will also add a standard text body
Jmail. Body = "too bad you can't read HTML-mail ."
Jmail. appendtext "There wowould have been a nice picture for 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.