Tom
Tom

Reputation: 3637

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:' + '[email protected]' + '?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?

Upvotes: 1

Views: 436

Answers (1)

Tom
Tom

Reputation: 3637

I should have through of it myself, but here goes:

do work

'mailto:[email protected]?subject=test'
'mailto:[email protected]?subject=test%20test'

does not work

'mailto:[email protected]?subject=test test'

(i.e. solution is to convert spaces to %20)

Upvotes: 2

Related Questions