woggles
woggles

Reputation: 7444

Using MVCMailer to embed image in email

How do you use MVCMailer to embed an image into a email?

I've tried something along the lines of

<img src="@Url.Abs("\\..\\images\logo.png")" \> 

with no success.

Any examples?

Thanks

Upvotes: 4

Views: 4812

Answers (3)

manuelmejiaio
manuelmejiaio

Reputation: 7017

You have to type the entire URL where your image is, and also it has to be hosted online.

So for example , i want to embed the image that is called Logo.png and it's located in the folder Images in my project , i'll write in the view of my MvcMailer:

<img src="http://mywebsite.com/Images/Logo.png" />

Upvotes: 1

Sohan
Sohan

Reputation: 3807

Look at the MvcMailer wiki

https://github.com/smsohan/MvcMailer/wiki/MvcMailer-Step-by-Step-Guide

search for Embed Image and you'll and you are done!

Upvotes: 5

Darin Dimitrov
Darin Dimitrov

Reputation: 1038930

Try like this:

<img src="@Url.Abs(Url.Content("~/images/logo.png")" /> 

Also make sure that the absolute url that is generated by this helper is accessible when you open the email in your mail client. For example if you hosted your ASP.NET MVC application in the local visual studio web server ensure that it is running when you try to read the email as the image must be accessible.

Upvotes: 3

Related Questions