Sachin Kainth
Sachin Kainth

Reputation: 46740

Images don't appear in emails

I have a HTML email template in the App_Data folder of my MVC application. In my code, I use this template to send HTML emails to users. This template references a few images in a folder in my project. The issue is that these images don't appear at all when the user receives the email. I have tried to reference the images using ~/path to image/image.gif. I have tried using ../../path to image/image.gif and I have copied the images to the App_Data folder and just referenced the images thus image.gif. Nothing is working. Does anyone have any suggestions?

Upvotes: 2

Views: 3717

Answers (4)

RuvenGam
RuvenGam

Reputation: 64

you can also use google picasa. upload the images to picasa, set the visibility to public, get in the album and on the right side you will have link to this photo link. press this link and chose the size you want it to be displayed, mark the image only check box and you will have a link ready to embed in to the mailer. put the link in the src and that is it.

Upvotes: 0

Antonio Bakula
Antonio Bakula

Reputation: 20693

As Jason said you have to put whole url, but if you put your image in App_Data they won't be accessible from outsite because this is a protected folder. You have another option to put images in mail, IMO this is a prefered way to put images in mail, e-mail client won't complain and ask for permission to display images. Here is a example how to do this

http://www.codeproject.com/KB/aspnet/EmbedImage.aspx

Upvotes: 1

Rahul.R.Parmar
Rahul.R.Parmar

Reputation: 84

The reason behind the image is not show in email because email client cannot get path you specified.

For the solution you can do below

  1. First replace the simple image URL to publically access url [means if you copy the image URL in browser you can access the browser], make sure your image folder is out of authentication

Upvotes: 1

Jason Meckley
Jason Meckley

Reputation: 7591

the images either need to be stored in a publicly accessible location with a full reference to the image <img src="http://my.domain.com/images/filename.ext" /> or the images need to be embedded into the email.

Upvotes: 7

Related Questions