2012-06-06 48 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