Send Email from IOS and Andoid [Edit]

Hi
I am trying to make an app that will send a standard email from either an Android or an ISO mobile app.
The email will always go to the same address but the body will change.

Can anyone point me to any sample or other code.

Thanks

Edited by: Bob Spencer on Jan 19, 2014 9:23 AM
-1
Bob
1/19/2014 5:24:05 PM
embarcadero.delphi.firemonkey 4901 articles. 2 followers. Follow

5 Replies
6406 Views

Similar Articles

[PageSpeed] 24

For iOS Matthias Eissing wrote an example: http://blogs.embarcadero.com/matthiaseissing/2013/05/03/38707/
The Blogpost is in German, but at the bottom is the whole Code. And the body has to be UrlEncoded (for example for a Space u need to write %20).

For Android this Post is very interesting:
http://www.danieleteti.it/2013/09/26/sending-android-intents-from-delphi-part-1/
If you look for the real Android-Intent in Java, it should be possible to send an E-Mail via Delphi. (I made it to start the E-Mail App, but only without the E-Mail Adress...). Unfortunately I haven't the Code right here...
-1
Christian
1/20/2014 5:49:08 AM
> {quote:title=Christian Artinger wrote:}{quote}
> For iOS Matthias Eissing wrote an example: http://blogs.embarcadero.com/matthiaseissing/2013/05/03/38707/
> The Blogpost is in German, but at the bottom is the whole Code. And the body has to be UrlEncoded (for example for a Space u need to write %20).
> 
> For Android this Post is very interesting:
> http://www.danieleteti.it/2013/09/26/sending-android-intents-from-delphi-part-1/
> If you look for the real Android-Intent in Java, it should be possible to send an E-Mail via Delphi. (I made it to start the E-Mail App, but only without the E-Mail Adress...). Unfortunately I haven't the Code right here...

Thank you for that Christian,

I am trying to send email at the press of a button without the user having to do anything more. Its to allow a message to be sent with data silently regarding their membership details etc.

So, would I have to make two entire applications? One for Android and the other for IOS or is there a way to make one code and decide the platform later such as conditional compiling etc.

Im relatively new to this mobile app development so please forgive any stupid questions I make ask.

Thanks
1
Bob
1/20/2014 7:25:56 AM
This is what i use for emailing from Android and iOS i hope you find it useful.

function TMainForm.OpenURL(const URL: string;
  const DisplayError: Boolean): Boolean;
{$IFDEF ANDROID}
var Intent: JIntent;
begin
Intent:= TJIntent.JavaClass.init(TJIntent.Javaclass.ACTION_SENDTO);
Intent.setData(TJnet_Uri.JavaClass.parse(StringToJString(URL)));
Intent.putExtra(TJIntent.JavaClass.EXTRA_SUBJECT, StringToJString('This is the subject of the email'));
Intent.putExtra(TJIntent.JavaClass.EXTRA_TEXT, StringToJString('This is a text for the body of the email '+
                                                               'This continues in the same line as the above'+
                                                               sLineBreak+'This will go in a new line'));
try
  SharedActivity.startActivity(Intent);
  exit(true);
except
on e: Exception do
begin
    if DisplayError then ShowMessage('Error: ' + e.Message);
    exit(false);
end;
end;
end;
{$ELSE}
{$IFDEF IOS}
var NSU: NSUrl;
begin
  NSU := StrToNSUrl(TIdURI.URLEncode(URL));
  if SharedApplication.canOpenURL(NSU) then begin
    exit(SharedApplication.openUrl(NSU))
    end
  else
  begin
    if DisplayError then
      ShowMessage('Error: Opening "' + URL + '" not supported.');
    exit(false);
  end;
end;
{$ELSE}
begin
  raise Exception.Create('Not supported!');
end;

{$ENDIF IOS}
{$ENDIF ANDROID}

And the code for the OpenUrl function is this
{$IFDEF ANDROID}
OpenURL('mailto:ASDADA@something.com');
{$ELSE}
{$IFDEF IOS}
OpenURL('mailto://ASDADA@something.com?Subject=This is the subject'+
                                    '&Body=This is the text of the body'+
                                    'And this will change line \n '+
                                    'This is written in a new line');
{$ENDIF IOS}
{$ENDIF ANDROID}


> {quote:title=Bob Spencer wrote:}{quote}
> > {quote:title=Christian Artinger wrote:}{quote}
> > For iOS Matthias Eissing wrote an example: http://blogs.embarcadero.com/matthiaseissing/2013/05/03/38707/
> > The Blogpost is in German, but at the bottom is the whole Code. And the body has to be UrlEncoded (for example for a Space u need to write %20).
> > 
> > For Android this Post is very interesting:
> > http://www.danieleteti.it/2013/09/26/sending-android-intents-from-delphi-part-1/
> > If you look for the real Android-Intent in Java, it should be possible to send an E-Mail via Delphi. (I made it to start the E-Mail App, but only without the E-Mail Adress...). Unfortunately I haven't the Code right here...
> 
> Thank you for that Christian,
> 
> I am trying to send email at the press of a button without the user having to do anything more. Its to allow a message to be sent with data silently regarding their membership details etc.
> 
> So, would I have to make two entire applications? One for Android and the other for IOS or is there a way to make one code and decide the platform later such as conditional compiling etc.
> 
> Im relatively new to this mobile app development so please forgive any stupid questions I make ask.
> 
> Thanks
1
Asder
1/20/2014 7:42:57 AM
I don't know if it works to send an E-Mail without user interaction (afaik the E-Mail Client always Opens and you have to press "Send").

You can use the same Project for Android and iOS. You have to use defines for that:

{code}
{$IF DEFINED(ANDROID)}
// Android Code here
{$ENDIF}

{$IF DEFINED(iOS)}
// iOS Code here
{$ENDIF}

{$IF DEFINED(iOS) or DEFINED(ANDROID)}
// iOS or Android Code here
{$ENDIF}
{code}
1
Christian
1/20/2014 7:45:35 AM
> {quote:title=Christian Artinger wrote:}{quote}
> I don't know if it works to send an E-Mail without user interaction (afaik the E-Mail Client always Opens and you have to press "Send").
> 
> You can use the same Project for Android and iOS. You have to use defines for that:

Nah i doubt you can do that. It would be kinda dangerous if you could do that i think. What exactly do you want to achieve? You could do some logging from your datasnap server or something else to record activity, or make a sharing function to share information that gets stored in a log.
-2
Asder
1/23/2014 7:15:18 AM
Reply:

Similar Artilces:

Send Email with Indy smtp
-- Indy component smtp and MailMessage -- under win 32 works correct, no problems. -- under debug for IOS Device: The IOS APP hang complete! -- lines source code: MailMessage.Recipients.EMailAddresses := empfaenger ; idEmailAdress.pas: line 715 EMail.Text := TrimLeft(AList); !!!!! no error nothing app hang! here is my source code: try try MailMessage.From.Address := 'sender.adress@...' ; MailMessage.Subject := 'Hello again'; MailMessage.Body.Text := Memo...

How do you rate you experience programming for IOS in Delphi/Firemonkey [Edit]
Hello: I've been taking a IOS programming course in objective-c/swift with xcode, and while doing my homework assignments I came to the conclusion that this is a very finicky environment, where very often things don't work as expected or there is always some minor UI glitch that has to be fixed or found workarounds for. Just to give you some examples (by far not an exaustive list): a UITableView doesn't align to the top when you use a navigation controller; upon selecting a row in a UITableView some buttons in the row disappear while the row is selected; specifying layout con...

Delphi XE8 FireMonkey iOS Style problem with segmented buttons [Edit]
Hi, Going through some tutorials to get used to mobile development using FireMonkey and Delphi XE8. One of the most basic layouts tend to use the toolbar component with segmented speed buttons, and then applying the correct segmented style to each button. However, there seems to be an issue with the iOS style. [Screenshot.|https://drive.google.com/file/d/0B68Ju-patBf-RVVEMmI5UDd2cG8/view?usp=sharing] Using the "segmentedbuttonleft", "segmentedbuttonmiddle", and "segmentedbuttonright" styles is producing an extra border on the right button in iOS. It seems...

Delphi XE4 - Firemonkey
I have an application that runs fine on windows, however when running on iOS simulator the onKeyUp event for a TEdit control is not being fired? Please advise if this event should get fired when running on iOS? This problem occurs onKeyUp events created directly on the control and by assigning the event programatically. Running XE4 update 1 iPhoneOS6.1.sdk Minimac: OS X 10.9 XCode 5 iOS Simulator Version 7.0 - iPad Retina / iOS 7.0.3(11B508) ...

How to make XE4 Firemonkey ios Component from native iOS UI controls ? [Edit]
Hi, I write this simple code for control volume in iOS {code} Var MPV : MPVolumeView; Procedure TForm1.SbPlayClick( Sender: TObject ); Begin MPV := TMPVolumeView.Wrap( TMPVolumeView.Alloc.InitWithFrame( CGRectMake( 20, 50, 200, 100 ) ) ); MPV.SetShowsRouteButton( True ); MPV.SetShowsVolumeSlider( True ); MPV.SetNeedsDisplay; WindowHandleToPlatform( Self.Handle ).View.AddSubview( MPV ); End; {code} MPVolumeView is a iOS UIView. with this line we can add iOS UIView elements into form, now how can add this elements into firemonkey controls ? {code} WindowHandle...

Mass Email sending or Bulk sending email
  i have a Problem regarding Email sending ie : Bulk sending mails --> let me explain Clearly i have an excel sheet in that there are around 3000 Records and in that each and ever record has a unique email id( it can be either gmail , yahoo. or hotmail )so , now i need a soluction for how to send a Bulk email at a timeas i told earlier  , each record contain Unique email id , so i need to send email for individual recodes in excel with appropriate record data  for the above probm , i have writen a program with foreach loop --> it is like, i have taken a co...

How to make XE4 Firemonkey ios Component from native iOS UI controls ? [Edit]
Hi, I write this simple code for control volume in iOS {code} Var MPV : MPVolumeView; Procedure TForm1.SbPlayClick( Sender: TObject ); Begin MPV := TMPVolumeView.Wrap( TMPVolumeView.Alloc.InitWithFrame( CGRectMake( 20, 50, 200, 100 ) ) ); MPV.SetShowsRouteButton( True ); MPV.SetShowsVolumeSlider( True ); MPV.SetNeedsDisplay; WindowHandleToPlatform( Self.Handle ).View.AddSubview( MPV ); End; {code} MPVolumeView is a iOS UIView. with this line we can add iOS UIView elements into form, now how can add this elements into firemonkey controls ? {code} WindowHandle...

Rule to send email on startup sends multiple emails
On client 6.5.7, creating a rule to send an email upon startup results in sending a continuous stream of emails until the rule is disabled and the client is restarted. I've found TID 3325376 referring to GW7, but nothing on 6.5.x. Any thoughts would be appreciated. Thanks as always. Len Bonk Network Analyst Community Unit School District 200 Len Bonk wrote: > 3325376 That bug was marked as "invalid". This is the explanaition from development about that particular bug: "This is working as designed. each time the client starts up it will process th...

A problem to send email using Smtp
I have a proble to send an email from asp.net I do the following code to send an email: MailMessage mail=new MailMessage(); mail.From="test@server.com"; mail.To="myemailaddress@server.com"; mail.BodyFormat=MailFormat.Html; mail.Subject="testing..."; mail.Body="cool"; SmtpMail.SmtpServer="localhost"; SmtpMail.Send(mail); But I dont' receive an email when I use this method. Why is that? How can I send an email? Thanks in advance! check and see if.. -your client-side code has no errors -you imported the S...

Programmatically send an email in iOS?
Does the Indy component idSMTP work under iOS? I am trying to develop an iOS app that will periodically send an email as a notification of something. I'd like to also be able to send a text message, separately. But first things first: I've tried to populate the idSMTP properties and it compiles and deploys to my iPhone just find, but when I call the method to send the email, the app just hangs. I have to wonder if idSMTP and the rest of the Indy component, like some of the other components in FireMonkey, just aren't compatible with iOS? Does anyone know of a good way to send e...

do-send-email, do-send-email-from-template attach a new file...
I like to do toolkit rules that report or fix things, based on a trigger attribute. Like these articles: http://www.novell.com/communities/node/6308/toolkit-rules-identity-manager-part-1 http://www.novell.com/communities/node/6310/toolkit-rules-identity-manager-part-2 http://www.novell.com/communities/node/6316/toolkit-rules-identity-manager-part-3 http://www.novell.com/communities/node/6440/toolkit-rules-identity-manager-part-4 http://www.novell.com/communities/node/6441/example-use-toolkit-rule-identity-manager http://www.novell.com/communities/node/6514/another-toolkit-rule-use-e...

How to send email using Delphi?
In the past, I used Jedi MAPI wrapper, but it won't work in Unicode Delphi where I get "General MAPI failure" " TmpEmail := TjclEmail.Create; TmpResolve := False; try TmpResolve := TmpEmail.ResolveName(TmpStr_Name, TmpStr_Email, True); except // new code for Delphi unicode... Also gives mapi failure end; if TmpResolve then TmpEmail.Recipients.Add(TmpStr_Email) else TmpEmail.Recipients.Add('smtp:' + TmpStr_Email) ; TmpEmail.Recipients[0].Name := TmpEmail.Recipients[0].Address; TmpEmail.Subject := 'bla bla...

sending email via Delphi
I am starting to use Delphi again after several years. I have Delphi 2010 with the Indy components that come with it. I want to send email from a Delphi app. I tried using the Indy components with some code I found on-line but with no success. Does anyone have some simple code that works well with the Indy components or know of a comprehensive email component I can buy. Thank you Whitney Whitney wrote: > I tried using the Indy components with some code I found on-line > but with no success. What is the actual problem you are having? What does your code actually l...

how to create send email [Edit]
hi every one, i dont english good, i will create a send mail for project but i can not create.i'm low level . please help me for create send email . i create my project with your help. it is hard? please help me .. how start for create send email from student to teacher or admin. i dont how teach for doing send email .whether need to create table in database? best regards. Edited by: fateme soleimani on Dec 21, 2013 3:32 AM Edited by: fateme soleimani on Dec 21, 2013 3:37 AM Edited by: fateme soleimani on Dec 21, 2013 3:43 AM Edited by: fateme soleimani on Dec 21, 2013...

Web resources about - Send Email from IOS and Andoid [Edit] - embarcadero.delphi.firemonkey

Asus may be cooking up another low-cost Andoid tablet
New benchmarks hint at a budget-minded Android 4.1 tablet with a 1GHz processor and a 1024×600 display.

Samsung set to unveil colorful Andoid tablets
Samsung Electronics has sent out invitations to a June 12 event in New York, at which the company is expected to launch new Android tablets. ...

Like Google Voice But Live Outside The US? Then Try VoxSci's New iO6/Andoid App
Google Voice remains a pretty useful service if you want your voice mails turned into text messages. However, it’s ability to do so accurately ...

Andoid - Tags - TechRadar
Andoid news and reviews on TechRadar

Lenovo ThinkVision 28 Smart 4K Andoid Display
... it is a complete instant-on experience. (more…) Follow: Computers , CES , CES 2014 , Lenovo , monitors , Lenovo ThinkVision 28 Smart 4K Andoid ...

TruckSpotting - CrunchBase Profile
TruckSpotting uses real time GPS to track Food Trucks and display their location relative to the user via IPhone and

Goodreads.com - LinkedIn
LinkedIn strengthens and extends your existing network of trusted contacts. LinkedIn is a networking tool that helps you discover inside connections ...

Android - MobiCity Australia
Online smartphone store selling the best new, unlocked mobile phones. Review, compare & buy online. Fast delivery, full Australian warranty ...

About Us
Amitech Business Solutions, Creative Technology Startup ventures , Innovative IT company of India, allevents.in trendround

Aliexpress.com : Buy MK806 Dual Core Mini PC Rockchip RK3066 1.6GHz 1GB RAM 4GB Android 4.1 with 3.5mm ...
... Shipping MK802 IIIs,High Quality Mk806 mini pc,China MK802 III Dual Core Mini PC Suppliers, Cheap MK802 III Dual Core android PC from Andoid ...

Resources last updated: 1/16/2016 8:48:47 AM