Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mailto and format (bold, italic, ...)

Tags:

html

href

mailto

I want to open the mail client of the user with a specific text. Some parts of the text should be bold, italic or u̲n̲d̲e̲r̲l̲i̲n̲e̲d̲.

I tried this by using mailto

But it use the RFC 2368... so this is not possible at all:

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.

Is there any other way to proceed to open the mail client with a specific formated template ?

like image 640
Atnaize Avatar asked Nov 09 '22 04:11

Atnaize


1 Answers

⚠ Do not use this unless you know your audience and have verified this does no harm to anybody.

And even then better refrain from using it, since it is more misuse than anything else: such content is mostly not accessible for assistive technology.


Since your question already includes "faux underline" (u̲n̲d̲e̲r̲l̲i̲n̲e̲) (mis)using combining low line character (Wiki),you probably know about other "faux alphabets", "twitter fonts" and similar shenanigans misusing other Unicode features, mostly various mathematical notations. With this dark knowledge you can just use proper URI encoding and browsers should pass the content to e-mail clients just fine:

var str = 'Please do not abuse "𝗯𝗼𝗹𝗱", "u̲n̲d̲e̲r̲l̲i̲n̲e̲", "𝘪𝘵𝘢𝘭𝘪𝘤" and other mathematical notations glyphs for ❝formatting❞.\nThanks!';
var href = 'mailto:?body=' + encodeURIComponent(str);
document.write((str + ' → ' + href).link(href));

Clicking resulting link produces this in gMail:

gmail compose window with textual abomination from the snippet

and generally should work in any other e-mail client. But again, test thoroughly and do not use if not absolutely necessary.

like image 165
myf Avatar answered Nov 15 '22 07:11

myf