简体   繁体   中英

Delphi XE4 iOS open email program not working

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?

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'

(ie solution is to convert spaces to %20)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM