Images don't appear in emails

别说谁变了你拦得住时间么 提交于 2019-12-30 11:12:42

问题


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?


回答1:


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.




回答2:


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



回答3:


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




回答4:


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.



来源:https://stackoverflow.com/questions/8732403/images-dont-appear-in-emails

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!