Closed GauravSgh closed 6 years ago
Hello @GauravSgh,
You will want to add the image as an inline attachment. Please try that and let me know how it goes. Thanks!
With Best Regards,
Elmer
@thinkingserious
I want to display image in email body instead of adding attachment,
Thanks
Yes, here is the relevant code:
var attachments = new List<Attachment>()
{
new Attachment()
{
Content = "base64 encoded string",
Type = "image/png",
Filename = "banner.png",
Disposition = "inline",
ContentId = "Banner"
},
new Attachment()
{
Content = "base64 encoded string",
Type = "image/png",
Filename = "banner2.png",
Disposition = "inline",
ContentId = "Banner2"
}
};
msg.AddAttachments(attachments);
These would be displayed inline using the following HTML:
<img src="cid:Banner"/>
<img src="cid:Banner2"/>
I hope that helps!
Yes it worked, thanks but still I am unable to control the size of image. I tried it in img tag by giving height and width but it was same as before. Is there any other way to control the size. Also can we use ico file type as well.
Hello @GauravSgh,
With regards to image sizes, perhaps this will help.
For .ico files, I believe you will have to convert it to an image format such as .jpeg or .png first.
With Best Regards,
Elmer
Hello @thinkingserious Thanks for the help its working fine. Just one last question, it supports multiple images as well right ?
Hello @GauravSgh,
Yes, you may pass in multiple Attachment
objects as demonstrated in the example code above.
Thanks!
With Best Regards,
Elmer
I am trying to put svg inside email body, but it is not rendering.
So basically I want to put a image inside a email body, initially I tried with tag but it didnt worked later I tried by using SVG but still i am not getting any image in the received email.
Code to send email:
`
`
And in EmailContent i am injecting html as:
<!DOCTYPE html><html><body><table><tbody><tr><td align='left'><div id="myDIV"><svg SVG_CONTENT</svg></div><label style='font-size:14px;font-family:Roboto-Regular;font-weight:normal;color:#676767;'></td><td align='left'><p><a href = 'SOME_URL'>SOMETEXT</a></p></label></td></tr></tbody></table></body></html>
Need a quick help. Let me know if any other information is required.