2012-06-06 44 views
2

我想使用ShellExecute,以便用户可以从他的默认电子邮件程序发送电子邮件;例如空白字符ofr在电子邮件中的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将为单一空间工作 - 有时候,但它不适用于行首或多个连续空间。这种“”不字符串内工作,要么:(

+0

检查%09(制表符)? –

回答

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在Windows 7 mailto工作雷鸟:

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

(使用嵌入0#9'More stuff'是'Stuff' + #9 + 'More Stuff'的简写,顺便说一句。

+0

这将把报价也,不知道它是否不受欢迎,但..(双引号是%22) –

+0

@塞尔塔克,我无法检查。使用Thunderbird的'mailto'在Win7上不适用于我。 'ShellExecute'返回'42',它应该表明它工作,但是TB不会打开一封新的电子邮件。 –

+0

我想要做的是排列一些列:标签似乎并不一致,因此我正在考虑放入空格。例如:“col1 col2 col3” – bobonwhidbey