简体   繁体   中英

send image in mail body using javascript

I want to embed an image in the mail body using javascript and jquery:

function SendEmail(StudyMail) {
     var emailBodyContent = "<span> " + greating + "</span> ,\n\n";
     emailBodyContent += " <img src=\"images/1.png\" />";
      DivMailBody.html(emailBodyContent);

        var body = DivMailBody.text();

        var contents = "".concat('mailto:' + StudyMail, '?subject= A new study', '&body=', encodeURIComponent(body));

        var pwin = window.open(contents, "_blank", "toolbar=yes, scrollbars=no, resizable=no, width=100, height=100");
        try {
            setTimeout(function () {
                pwin.close();
            }, 100);
        } catch (e) {
        }
}

it sends the mail without the image.

You must you image tag like below and emmbed your image inside your html page

<img src=\"cid:filename\">

for embedding image you can use the following linke

embedding image in html email

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM