Search code examples
delphimailto

Delphi - Sending Email which contains line feeds


Using Delphi 2010, I am trying to send email in which the BODY of the email needs to be multi-line. I cannot get the multi-line part to work. I have tried inserting #13, and #10, and '%0d'. It either ignores and prints everything as one line, or I get an external exception.

Here is my source code.

  strEmail := '[email protected]';
  strSubject := 'Update Request: ';
  strBody := 'Line1 ' +#13 + 'Line 2';


  Param := 'mailto:' + strEmail + '?subject=' + strSubject + '&Body=' + strBody;
  Shellexecute(Main.Handle, 'open', PChar(Param), nil, nil, SW_SHOWNORMAL);

How do I get Line1 and Line2 on separate lines in the Body of my email? You can assume that the only email client will be Outlook. (Different versions may be used.)

Thanks,

GS


Solution

  • According to the mailto URL scheme RFC 2368, you have to use the %0D%0A for line breaks. There's directly a note about it (removed double quotes):

    Also note that line breaks in the body of a message MUST be encoded with %0D%0A.