Delphi XE4 iOS open email program not working

风格不统一 提交于 2019-12-12 23:02:09

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!