HTML EMail with embedded images
-
Hi, How can I generate EMails with HTML and send them using C# / .net. Sorry but I have no idea about how that kind of e-mail works ( if there is an standard format to have the pics and content embedded or...). Thanks in advance, Greetings Braulio
-
Hi, How can I generate EMails with HTML and send them using C# / .net. Sorry but I have no idea about how that kind of e-mail works ( if there is an standard format to have the pics and content embedded or...). Thanks in advance, Greetings Braulio
This is done using MIME (Multipurpose Internet Mail Extensions). You should first understand how SMTP works and how basic email messages are formatted. It's similar in concept to HTTP, in that you provide headers, skip a line, and begin your content. MIME adds content types, including multipart which allows you to include text, html, images, and more. Image should, of course, be encoded as text (typically base64-encoded, but could be anything so long as clients support it). For some information about MIME, you can google. There is a specific section on MSDN, MIME Extensions to Internet Mail[^] (kinda of redundant, but oh well) that also includes a sample of a MIME message. It also includes information on many common types used in MIME messages, but you can use anything so long as it can be interpreted by the email client (if it isn't, only the parts of the email that are understood are displayed).
Microsoft MVP, Visual C# My Articles
-
This is done using MIME (Multipurpose Internet Mail Extensions). You should first understand how SMTP works and how basic email messages are formatted. It's similar in concept to HTTP, in that you provide headers, skip a line, and begin your content. MIME adds content types, including multipart which allows you to include text, html, images, and more. Image should, of course, be encoded as text (typically base64-encoded, but could be anything so long as clients support it). For some information about MIME, you can google. There is a specific section on MSDN, MIME Extensions to Internet Mail[^] (kinda of redundant, but oh well) that also includes a sample of a MIME message. It also includes information on many common types used in MIME messages, but you can use anything so long as it can be interpreted by the email client (if it isn't, only the parts of the email that are understood are displayed).
Microsoft MVP, Visual C# My Articles
-
Heath , why don't you advise him
MailMessage
Class? Mazy "Improvisation is the touchstone of wit." - MolièreMazdak wrote: Heath , why don't you advise him MailMessage Class? While you can send standard HTML with the
MailMessage
class, the poster originally asked about embedding content including images which would require the use of MIME as Heath noted. - Nick Parker
My Blog -
Heath , why don't you advise him
MailMessage
Class? Mazy "Improvisation is the touchstone of wit." - MolièreBecause it doesn't allow you to send pictures as part of the HTML body, only to include a URL from an external resource. You can include attachments, but without using the right MIME header the HTML body won't resolve the attached image correctly.
Microsoft MVP, Visual C# My Articles