问题
I am testing the following code on an iPhone4 (without sim card, but I don't see how that can matter since its mail program is otherwise working fine):
The SharedApplication and canOpenURL etc. are all routines provided by XE4.
procedure TFormMain.sbContactsDetailsEmailClick(Sender: TObject);
var
S: string;
NSU: NSUrl;
begin
// URL.stringByAddingPercentEscapesUsingEncoding(NSUTF8StringEncoding);
S := 'mailto:' + 'info@example.com' + '?subject=' + 'title' + '&body=';
NSU := StringToNSUrl(S);
if SharedApplication.canOpenURL(NSU) then
SharedApplication.openUrl(NSU)
;
end;
Unfortunately, it seems SharedApplication.canOpenURL(NSU) returns false. Am I doing anything wrong?
回答1:
I should have through of it myself, but here goes:
do work
'mailto:info@example.com?subject=test'
'mailto:info@example.com?subject=test%20test'
does not work
'mailto:info@example.com?subject=test test'
(i.e. solution is to convert spaces to %20)
来源:https://stackoverflow.com/questions/17958950/delphi-xe4-ios-open-email-program-not-working