In my MVC4 application, I am using the postal package for sending emails.
I am trying to include a logo via an <img>
tag, but it's not working.
How can I include my company logo?
Controller Action:
public ActionResult Index()
{
dynamic email = new Email("Example");
email.To = "xxxxx@xxxxxx";
email.FunnyLink = "haiii";
email.Send();
return View();
}
View:
To: @ViewBag.To From: lolcats@website.com
Subject: Important Message
<div style="background-color:aqua;">
Hello, You wanted important web links right?
Check out this: @ViewBag.FunnyLink
<br />
<img src="~/Images/Logo.png" />
</div>
You need to use full absolute image urls like this-
<img src="@Request.Url.GetLeftPart(UriPartial.Authority)/Images/Logo.png" />
or
If you're having html based files then you should send the domain name just like the other data you're passing into the view like this-
<img src="@ViewBag.DomainName/Images/Logo.png" />
When your email would be received by the users then the content of your email would not resolve the image path from relative urls like this -
/Images/logo.png {this will not work}
So the images can only be fetched if having full domain path.