English 中文(简体)
如何在电子邮件模板中插入形象
原标题:how to insert image into email template

I m试图利用ASP的密码检索。 NET。

不过,我正在使用电子邮件模板。 在这份电子邮件中,Im试图插入以下形象:

<html xmlns="http://www.w3.org/1999/xhtml">

<body>

<img alt="blabla" src="/Images/blabla-logo.png" align="middle"/><br/><br/>
bla bla:<%Password%><br /><br />
</body>

</html>

正如我说过的那样,电子邮件正在被罚款,但图像没有插入。 我尝试过:src=“~/Images/bla-logo.png”,但没有成功。

是谁?

Thanks a lot, Assaf.

问题回答

对于电子邮件,你不应给内部网页上唯一的工程提供像“Images/bla-logo.png”这样的相对途径,而不应让你这样一条完整的道路。

http://youserver/youapp/Images/bla-logo.png” rel=“nofollow noreferer” http://youserver/youapp/Images/bla-logo.png

我将建议你不要把图像用在路上,而不要把图像放在你的电子邮件中。 你们可以通过将图像转换成64的图象,并将64的基体作为图像的源头。

你可以利用网上邮件活动来修改你的电子邮件信息。 让我假定一下您的模板:

<html xmlns="http://www.w3.org/1999/xhtml">
  <body>
    <img alt="blabla" src="{0}" align="middle"/><br/><br/> 
    bla bla:<%Password%><br /><br /> 
  </body>
</html>

你们的口号是:

<asp:PasswordRecovery ID="prPasswordRecovery" runat="server" OnSendingMail="prPasswordRecovery_SendingMail">
  <MailDefinition BodyFileName="~/passwordRecoveryEmailTemplate.txt" IsBodyHtml="true" Priority="High" Subject="bla bla"/>
</asp:PasswordRecovery>

最终要做的是,在以下编码中写写“新字”——邮电:

protected void prPasswordRecovery_SendingMail(object sender, MailMessageEventArgs e)
{
  e.Message.Body = String.Format(e.Message.Body, ResolveClientUrl("~/Images/blabla-logo.png"));
}

这样做。

尝试添加“~”,一种id和 run子=“服务器”。 只有在应用“维护者”时,til才改变为根本道路。 否则,服务器代码对控制没有了解,没有穿过控制线,也没有采用插入途径。

 <img alt="blabla" src="~/Images/blabla-logo.png" 
 align="middle" id="img" runat="server"/>

您是否利用候补意见进行了审判?

其中一个例子是here





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签