0

I am attempting to add an image to string builder which i'm generating for sending an email. However I can't seem to get the image to be displayed in the email but I can get it attached. I'm using mymail.Attachments.Add(new Attachment(HttpContext.Current.Server.MapPath("~/Content/" + qrID + ".png"))); and that attaches fine but the following does not work

        string mapPath = $"/~Content/{qrID}.png";
        StringBuilder sb = new StringBuilder();
        sb.Append(
            "<table>" +
            "   <tr>" +
            "       <td>Image: </td>" +
            "       <td><img src =\"HttpContext.Current.Server.MapPath(" + mapPath + " )>" +
            "   </tr>" +
            "</table>");

Appreciate some help in getting my image to show on my email

Regards

Niana
  • 977
  • 2
  • 13
  • 38
  • 2
    You appear to be creating a link to an image, if you want to embed the image, then you need to create a multipart email, with special markers in it. If you DO just want a link, then make sure your MapPath is externally visible on your server. – Neil Jul 15 '21 at 16:57

0 Answers0