HTML <base> tag in email

守給你的承諾、 提交于 2019-12-05 05:38:46

Unfortunately, it won't work for most web-based email clients (Hotmail, Gmail) and that typically adds up to about 30% of receivers.

Why it won't work: Most web-based clients inject whatever's inside the body tag of your email and strip out everything else, including the head. So, if you send:

<html>
<head><base ...></head>
<body><p class="youremail">Email</p></body>
</html>

The email client does this:

<html>
<head><Email client head></head>
<body>
  <email client wrapper>
  <email>
    <p class="youremail">Email</p>
  </email>
  <email client wrapper>...
</body>

So your base tag will be stripped. Even if it wasn't, since it's not include in the email client's head, it will be ignored by the browser.

Unfortunately, absolute paths on images is the way to go. I have got over similar problems in the past by using a 'preflight processor'. You could use that to get the <base> href and set it on all the images before returning the finished HTML.

I couldn't tell if your using Razor or not, but if you are, you can do this inside a razor view:

src="@Request.Url.GetLeftPart(UriPartial.Authority)~/images/screenshot.png"
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!