. NET send inline picture messages in the correct way

Source: Internet
Author: User
Tags custom name net send

Many enterprises send the mail is illustrated, some of which are in the mail quote online image URL, more professional way is directly in the mail through the inline attachment embedded pictures, this feature can be implemented by some mail client programs, then how we are in. NET to achieve this function?

Search for a bit, found a person, but this method verified by me is wrong, the other did not find any useful information.

After trying, I found the right way, and it's very simple:

1. Set the ContentID property of the attachment to a custom name.

2. Set the Contentdisposition.inline property of the attachment to true.

3. In the text of the message in the HTML format of the "CID: Custom Name" In the way cited, such as ContentID set to "face", then the body in the "cid:face" as its URL path string replacement can be.

Originally I used this method in writing to make the link in the message point to the attachment, and as a picture display is only one more set as an inline attachment of the steps.

Take a look at the complete test code:

The obscure part is the email address, username, password, no need to care.

In the above test, the final component of the message content code is:

<a href= "cid:mypic" target= "_blank" > click on the New window to open the picture </a>

When the mail client receives this message, it will automatically convert the reference code to the actual URL address.

This is the e-mail effect that is received in Gmail:

This is 126:

I do not use the desktop version of the mail client, so did not go to test the desktop client offline reading effect, but it is certainly no problem, this is the embedded picture's biggest advantage.

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.