I've found this link on how to using Razor Engine for email templates in asp.net and it worked great. But I've tried to have a logo in the email template with an image.
Something like this:
EmailTemplate.cshtml
(this by the way is a strongly-type view)
<html>
<body>
<img src="logo.jpg" />
</body>
</html>
and when I try to submit it on email, it seems that the image path was not read, it only rendered an X in the content.
I'm thinking to pass the image path as part of the Model but it seems odd that way. Is there any way to achieve this?
Any help would be much appreciated. Thanks
To see image everywhere you can use these options:
Absolute Url
You can simply use full absolute path of image for example
"http://example.com/images/logo.png"
IMO It is the most simple option and recommended for your problem.
Attachment
As mentioned by Mason in comments You can attach image to mail and then put image tag and use
ContentId
of attachment:Data Uri
you can use data uri (data:image/png;base64,....).
Not Recommended because of weak support in most of mail clients, I tested it with
Outlook.com(web)
andOutlookWebAccess(web)
andOffice Outlook(Windows)
andOutlook(windows 8.1)
and unfortunately it worked only onOutlookWebAccess(web)
.