2

我想使用 ShellExecute 以便用户可以从他的默认电子邮件程序发送电子邮件;例如

const
  CRLF = '%0D%0A';
var
  Body: string;
begin
  Body := 'Information from my program'+CRLF+
      'that is put in the body of the email'; 
  ShellExecute(Application.Handle, 'open', PChar('?Subject=My Subject&Body=' +  
      Body),nil, nil, SW_SHOWNORMAL);

我想用信息列格式化正文。我怎样才能放一个空白?似乎 %20 将适用于单个空格 - 有时,但它不适用于一行的开头或几个连续的空格。这个 ' ' 也不起作用:(

4

1 回答 1

2

Chr(34)在字符串中使用双引号 ( ):

Body :=  #34 + 'Information from my program' + CRLF +
      'that is put in the body of the email' + #34; 
ShellExecute(Application.Handle, 'open', 
    PChar('?Subject=My Subject&Body=' + Body), nil, nil, SW_SHOWNORMAL);

要排列列,您可以尝试使用制表符 ( Chr(9)) - 正如我在评论中所说,我无法ShellExecute使用mailtoThunderbird 在 Windows 7 上使用:

Body :=  #34 + 'Information from my program' + CRLF +
      'that is put in the body of the email' + CRLF +
      'Col1'#9'Col2'#9'Col3' + #34; 

(使用Stuff#9'More stuff' 嵌入是'Stuff' + #9 + 'More Stuff', BTW 的简写。

于 2012-06-06T01:36:12.197 回答