Tuesday, October 4, 2011

Sending an email from an iOS FireMonkey application

Q: How do you send an email from the iPhone using FireMonkey?
A: By opening a mailto URL

Below is a very simple unit that will do the trick. Just create a brand new iOS FireMonkey application, and add two edit boxes and one memo. The first edit box will hold the email address we're sending the email to. The second edit box will contain the subject line, and the memo will contain the actual email body.

Notice that this opens the local email client and you have to send it manually. It does *not* send the email in the background.


unit Unit1;

{$mode objfpc}{$H+}
{$modeswitch objectivec1}


SysUtils, Types, UITypes, Classes, Variants, FMX_Types, FMX_Controls, FMX_Forms,
FMX_Dialogs, FMX_Layouts, FMX_Memo, FMX_Edit
, iPhoneAll

TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
Label1: TLabel;
Edit2: TEdit;
Label2: TLabel;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
{ Private declarations }
{ Public declarations }

Form1: TForm1;


{$R *.lfm}

procedure TForm1.Button1Click(Sender: TObject);
ToStr, SubjectStr, BodyStr : String;
URL : NSString;

ToStr := Edit1.Text;
SubjectStr := Edit2.Text;
BodyStr := Memo1.Text;

URL := NSSTR(PChar('mailto:'+ToStr+'?subject='+SubjectStr+'&body='+BodyStr));
URL := URL.stringByAddingPercentEscapesUsingEncoding(NSUTF8StringEncoding);




  1. Hello,
    I've tried the example and sometimes it does not work. The fault must lie here on this line:

    URL: = URL.stringByAddingPercentEscapesUsingEncoding (NSUTF8StringEncoding);

    UIApplication.sharedApplication.openUrl (NSURL.URLWithString (URL));

    If Xcode launches the iPhone simulator, it reports these lines, that something is wrong.

    Can you help me?

  2. That's correct. The Mail app doesn't exist on the simulator. This demo only works on a device that has at least one email account setup in the Mail app.

  3. Even if I want to transfer the app from Xcode on the device (iphone) Xcode brings me out of error messages.
    In the uses - is part involved iphoneall yes, I put the app into iphoneall.pas directory he wants all * inc files, if I leave out my Xcode also brings the error messages..

  4. I'm afraid I don't understand what you're doing. If you installed FreePascal and FireMonkey on the Mac from the FireMonkey_iOS.dmg file, everything should just work. iPhoneAll.pas is part of FPC and so are all the *.inc files.

    Put your own app in your own directory. Do not put it in the directory where iPhoneAll.pas is located.

    Better yet, simply use my set of components located here:


    FMX_Email is the demo you would use for sending emails.

  5. Email Marketing might seem like a cost effective way to deliver your email list marketing messages. For the most part, bulk email marketing is because you can send personalized, targeted and interest - specific messages to a large mass of emails of people. The value of email list marketing does not end with cost, however. Email Marketing has certain advantages over other forms of direct marketing for your business and for the email list addresses from people that requested and recieve email marketing.

  6. We must have our own beliefs.
    louis vuitton http://www.asit.biz/public/xml/configuration.asp

  7. Great goods from you, man. I've have in mind your stuff previous to and you're simply too fantastic. I actually like what you have got right here, really like what you're saying and the way in which wherein you say it. You make it entertaining and you continue to care for to keep it sensible. I cant wait to learn far more from you. That is really a terrific site.

  8. I've read several excellent stuff here. Certainly worth bookmarking for revisiting. I wonder how a lot attempt you set to create one of these wonderful informative site.

  9. I simply much like the worthwhile information and facts anyone supply inside your content articles. I am going to take note of your site plus have a look at yet again the following regularly. I will be rather selected I will find out many completely new products suitable in this article! Good luck for the next!

  10. I agree that wear what you want.
    bloger http://www.hojlind.dk/administrator/ozvircs.asp

  11. Hello, Cool post. You will find there's challenge with your website in traveler, would click here? Web browser however may be the market place head in addition to a massive aspect of others will omit your current fantastic composing for that reason challenge sms advertising.

  12. Great blog right here! Also your website quite a bit up fast! What web host are you the usage of? Can I am getting your affiliate link to your host? I desire my website loaded up as fast as yours lol

  13. This is very fascinating, You are an excessively professional blogger. I have joined your feed and stay up for in the hunt for extra of your magnificent post. Additionally, I've shared your website in my social networks

  14. I do rely on many of the thoughts you've got presented on the posting. They're extremely persuading all of which will definitely do the job.. iPhone 7 new concept Nevertheless, the particular posts are extremely speedy for starters. May just you please expand all of them a little bit coming from subsequent occasion? We appreciate you a write-up.

  15. I don't even understand how I stopped up here, however I assumed this publish was once great. I don't understand who you are but certainly you're going to a well-known blogger in the event you aren't already. Cheers!

  16. You can certainly see your enthusiasm within the paintings you write. The arena hopes for even more passionate writers such as you who aren't afraid to say how they believe. All the time follow your heart.

  17. Hi there! I know this is kinda off topic but I was wondering which blog platform are you using for this site?
    I'm getting sick and tired of Wordpress because I've had issues with hackers and I'm looking at alternatives for
    another platform. I would be fantastic if you could point
    me in the direction of a good platform.

  18. Simply wish to say your article is aas amazing. The clarity in your put up
    is just nice and that i could suppose you are a professional in this
    subject. Well with your permission let me to grasp your
    RSS feed to tay upp too date with cooming near near post.

    Thanks 1,000,000 and pleease continue tthe gratifying work.

  19. I was recommended this web site by way of my cousin. I'm no longer
    sure whether or not this publish is written by him as nobody else recognise such specific approximately my trouble.

    You are incredible! Thank you!

  20. Search engines started getting cluttered with sites that spammed their content with the abuse of relevant keywords.

    For all types of businesses, having your own website is a plus
    and an advantage. Here you would get a great Hebrew interlinear
    Bible, but the issue is cost.

  21. Hello, I enjoy reading through your post. I wanted to write a
    little comment to support you.

    Here is my webpage; Star Wars Commander Hack

  22. I am regular visitor, how are you everybody?

    This article posted at this website is really good.

    Visit my webpage: racing rivals cheats android

  23. This is great when you are getting pounded by a group. When Roman Catholic Spain began colonizing, they found that “All Souls
    Day” coincided with Native American traditions regarding the
    souls of the dead, and thus the “Day of the Dead”
    was established. Eradication-3 Hitting with Corruption gives you a chance to increase casting.

    my web-site Minion Rush Free Tokens

  24. I would like to let you know about a new product called Social Pop and it's two functions...

    I found a great......

  25. I would like to inform you about a new product called Social Pop and it's two functions...

    I found a great......

  26. I used the Social Pop application or plugin actually, I could visit a substantial escalation in conversion rates|As I used plugin or the Social Pop application actually, I could see a substantial[...]...

    I found a great......

  27. A person necessarily help to make significantly
    articles I'd state. That is the very first time I frequented your web page and up to now?
    I surprised with the research you made to create this
    actual post amazing. Wonderful job!

    My website :: throne of spirits hack ios

  28. Yesterday, while I was at work, my cousin stole
    my iphone and tested to see if it can survive a 30 foot drop,
    just so she can be a youtube sensation. My iPad is now broken and she has 83 views.
    I know this is totally off topic but I had to share it with someone!

    My homepage - Iron Knights Hack

  29. I think this is one of the most important information for me.
    And i'm glad reading your article. But want to
    remark on few general things, The website style is perfect, the articles is really great : D.
    Good job, cheers

    Visit my web-site: line disney tsum Tsum hack tool

  30. Supercharge your marketing campaign with our social media promotion services. Buy high quality likes/followers/views at highly competitive prices and with fast delivery.

    Get 1,000 Google+ Ones from:- http://khalaghor.com/google.html
    5) 5,000 Instagram Followers from:- http://khalaghor.com/instagram.html

    You can also order smaller or bigger package from our official website.

  31. Hey there I am so glad I found your website, I really found you by mistake, while I was searching on Digg
    for something else, Nonetheless I am here now and would just like to say cheers for a
    remarkable post and a all round enjoyable blog (I also love the theme/design), I don't have time to go through it all at the
    moment but I have saved it and also added in your RSS
    feeds, so when I have time I will be back to read much more,
    Please do keep up the superb work.

    Review my web site - drone shadow strike hack tool

  32. You will see progres bar, and when it finishes you get your items in 30 secons period.
    After making the cut they went on to define an issue that affected the world and to develop a strategy.
    It will support USB2 AND USB3, have 512GB of solid-state storage, and a 720p Face - Time
    HD camera.

    Feel free to surf to my weblog ... csr Racing Hack Android

  33. Supercharge your marketing campaign with our social media promotion services. Buy high quality likes/followers/views at highly competitive prices and with fast delivery.

    Get 5,000 Twitter Followers from:- http://khalaghor.com/twitter.html

    You can also order smaller or bigger package from our official website.