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.