Hi,

How can i break body message into pagagraphs?
Example; Example below should be like this.

Hi,
How are yo today.
Bye

<input type="button" value="Unsubscribe" onClick="parent.location='mailto:contactus@mymail?subject=Subscribe%20to%20Whatever&body=Hi,How are yo today.Bye">

Dani AI

Generated

Short answer: was on the right track — the mailto body must be URL-encoded and you should prefer encoding CRLF (carriage-return + line-feed) for paragraph breaks so clients interpret them consistently. See the mailto URI rules in RFC 6068 for the spec.

A reliable pattern is to build the text in JavaScript, join paragraphs with CRLF, then run encodeURIComponent on the subject and body so every special character is encoded correctly. Example:

var subject = 'Subscribe to Whatever';
var paragraphs = ['Hello,', 'This is line one of the message.', 'Regards'];
var body = paragraphs.join('\r\n\r\n'); // CRLF between paragraphs
window.location.href = 'mailto:contactus@mymail?subject='
  + encodeURIComponent(subject)
  + '&body=' + encodeURIComponent(body);

Notes and troubleshooting:

  • encodeURIComponent handles encoding for you; see the docs on encodeURIComponent.
  • Mailto carries plain text only — you cannot rely on HTML formatting in the body.
  • Keep mailto payloads short. Very long bodies may be truncated by browsers or mail handlers and URL length limits vary by client.
  • Some mail clients or webmail handlers treat mailto parameters differently; always test with the targets you care about.
  • For unsubscribe buttons, a server-side one-click link is a better UX and more reliable than relying on the user to send an email.

Recommended Answers

All 2 Replies

Hi Veledrom,

Use "%0A" for a new line, use "%0A%0A" for a new line preceded by a blank line.

Eg:

<input type="button" value="Unsubscribe" onClick="parent.location='mailto:contactus@mymail?subject=Subscribe%20to%20Whatever&body=Hi,How are yo today.Bye.%0A%0AThis mail was sent using www.example.com" website.>

Perfect. Thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.