Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am able to attach image in email attachment but unable to attach image inside anchor tag with link.

C#
<a href='" + Url + "'><img src=cid:companylogo/></a>

<a href='http://Link'><img src=cid:companylogo/></a>

<a href="http://localhost:3560/Home/View/3">><img src=cid:companylogo/></a>

Link on > working but on attached image link not working. Interesting thing is both > and image are inside anchor tag.


C#
Attachment imgattm = new Attachment(HttpContext.Current.Server.MapPath(@"/Content1/img/key-login-icon.png"));
                imgattm.ContentId = "companylogo";
                mail.Attachments.Add(imgattm);


above code send image with attachment on email but href link not working.

if anyone have idea please help.
Posted
Updated 20-Nov-18 14:54pm
v6
Comments
F-ES Sitecore 12-Oct-15 4:20am    
Does the email literally contain

<a href='" + Url + "'>

? If so it won't work as the email client isn't going to execute javascript. You'll need to make sure the code that sends the email generates html that has the url in place already.
itsathere 12-Oct-15 4:25am    
when i placed '>' this link working but image link not working.you can see the below code

><img src=cid:companylogo/>

Most email clients will block image downloads so it isn't that your code is wrong, it's that the client email is blocking it. You can't do anything about that. The client needs to choose to download the image.
 
Share this answer
 
Hi,

C#
.login {
  background: url(../img/user.png) no-repeat 6px center;
  width: 100px;
  height: 100px;
  display: block;
}



Or,

C#
<a href="#" class="login" title="Login"><img src="../img/user.png" /></a>


Follow the link for more details:
http://www.createafreewebsite.net/anchor_tag_image.html[^]

Thanks,
-V
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900