Wednesday, 8 February 2017

C# Embed Image to Email

If the image is not embedded in the email, the recipient might not be able to see the image (e.g. in email signature). So use the following code to embed the image into HEML email:

// get the actual image url and assign id (content id) and assign a unique id to the image
Attachment imgAtt = new Attachment(@"C:\Images\DesireImage.jpg");
imgAtt.ContentId = "image";
email.Attachments.Add(imgAtt);

Add the image (with its unique id) to the body of the html email:
<img src='cid:image' />


No comments:

SQL: Generate a range of numbers

SELECT ones.n + 10*tens.n + 100*hundreds.n + 1000*thousands.n FROM       (VALUES(0),(1),(2),(3),(4),(5),(6),(7),(8),(9)) ones(n),      (VALU...