0

I creating emails using partial views and saving them in DB (later they will be sent). I need to embed image into email to display in gmail. How to do this in ASP.NET MVC 2 project? How to embed image into view to make it work and display image in gmail?

Bohdan Kuts
  • 607
  • 15
  • 23

1 Answers1

1

You can't. Well, not reliably anyways. At least not in the way you mean. There is such a thing as data-url's, that allow you to embed an image into the page, but you will find that this is not widely supported by email clients and thus is not a reliable way to include images.

In fact, creating emails with embedded content is something of a black art. There are so many gotchas with various email client support that you have to do a lot of research into what does and doesn't work.

However, in general, what you want to do is use an embedded MIME image attachment in the email multi-part mime format, which has nothing whatsoever to do with MVC. All you would do in MVC is create your email with the appropriate tag (ie. <img src="cid:logo_sml.jpg">) to extract the mime content from the email, note that you won't see anything in a browser, as it only works in an email client.

You might want to read articles like these:

Community
  • 1
  • 1
Erik Funkenbusch
  • 92,674
  • 28
  • 195
  • 291