简体   繁体   中英

Can I create a email from a mailto: link which is prepopulated with an image?

so I have a link like this:

mailto:someone@nowhere.com?subject=Hello%20You&body=Some%20Body%20Text

and I'd like it to open an email which has an image (ideally) embedded in the mail, or attached to the mail. Ideally I'd also like to add a Table from Excel to the mail as well.

mailto:someone@nowhere.com?subject=Hello%20You&body=Some%20Body%20Text%0A<a%20href="image.jpg"/>

Is this possible or am I living in dream land?

Short Answer

No.

Long Answer

It is not possible to send a Image (as HTML), according to the specification RFC2368

The special hname "body" indicates that the associated hvalue is the body of the message. The "body" hname should contain the content for the first text/plain body part of the message. The mailto URL is primarily intended for generation of short text messages that are actually the content of automatic processing (such as "subscribe" messages for mailing lists), not general MIME bodies.

http://www.ietf.org/rfc/rfc2368.txt

So what i should do?

Your best bet would be, to have a server side formular.

<form action="/pathto/serverside/mailer" method="post">
    <input type="text" name="name" placeholder="Your name" />
    <input type="text" name="mail" placeholder="Your email-adress" />
    <input type="text" name="message" placeholder="Your message" />
    <input type="submit" value="Send">
</form>

PHP Way

$mail = new PHPMailer;
$mail->IsSMTP();
$mail->Host     = $host;
$mail->SMTPAuth = true;
$mail->Username = $username;  
$mail->Password = $password; 
$mail->From     = $from;
$mail->FromName = $fromName;
$mail->AddAddress($to , $toName);
$mail->Subject  = $subject;
$mail->Body     = $body; //Your Html
$mail->IsHTML(true); 

This is based on the PHPMailer Library https://github.com/PHPMailer/PHPMailer , because the built in mail() function is the devil in person ;)

ASP Way

MailMessage mail = new MailMessage(from, to, subject, message);
mail.IsBodyHtml = true;
SmtpClient client = new SmtpClient("localhost");
client.Send(mail);

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