How to send email from your application


SDK Version: 
M3

Today we'll create an easy email sender application.
First of all we need to create a layout to set the address, the subject and email body box.

  1. <?xml version="1.0" encoding="utf-8"?><LinearLayout android:id="@
  2.  
  3. +id/LinearLayout01" android:layout_width="fill_parent"
  4.  
  5. android:layout_height="fill_parent"
  6.  
  7. xmlns:android="http://schemas.android.com/apk/res/android"
  8.  
  9. android:orientation="vertical"><LinearLayout android:id="@+id/LinearLayout02";
  10.  
  11. android:layout_width="wrap_content" android:layout_height="wrap_content"
  12.  
  13. android:orientation="horizontal"><EditText android:layout_width="wrap_content"
  14.  
  15. android:layout_height="wrap_content" android:width="170dip" android:id="@
  16.  
  17. +id/emailaddress"></EditText><TextView android:layout_width="wrap_content"
  18.  
  19. android:layout_height="wrap_content" android:id="@+id/emailaddress"
  20.  
  21. android:text="Email address"></TextView>
  22. </LinearLayout>
  23.  
  24.  
  25. <LinearLayout android:id="@+id/LinearLayout03";
  26.  
  27. android:layout_width="wrap_content" android:layout_height="wrap_content"
  28.  
  29. android:orientation="horizontal"><EditText android:layout_width="wrap_content"
  30.  
  31. android:layout_height="wrap_content" android:width="170dip" android:id="@
  32.  
  33. +id/emailsubject"></EditText><TextView android:layout_width="wrap_content"
  34.  
  35. android:layout_height="wrap_content" android:id="@+id/emailsubject"
  36.  
  37. android:text="Subject"></TextView>
  38. </LinearLayout>
  39. <EditText android:layout_width="wrap_content"
  40.  
  41. android:layout_height="wrap_content" android:lines="5" android:width="300dip"
  42.  
  43. android:id="@+id/emailtext"></EditText>
  44. <Button android:layout_width="wrap_content" android:layout_height="wrap_content"
  45.  
  46. android:id="@+id/emailsendbutton&quot; android:text="Send!"
  47.  
  48. android:width="150dip"></Button>
  49. </LinearLayout>

Ugly, but works...
Next we create a new class, called ....uhhhm...Email, then modify like this:

  1. import android.app.Activity;
  2. import android.content.Intent;
  3. import android.os.Bundle;
  4. import android.view.View;
  5. import android.view.View.OnClickListener;
  6. import android.widget.Button;
  7. import android.widget.EditText;
  8.  
  9. public class Email extends Activity {
  10.         Button send;
  11.         EditText address, subject, emailtext;
  12.     @Override
  13.     public void onCreate(Bundle savedInstanceState) {
  14.         super.onCreate(savedInstanceState);
  15.         setContentView(R.layout.email);
  16.         send=(Button) findViewById(R.id.emailsendbutton);
  17.         address=(EditText) findViewById(R.id.emailaddress);
  18.         subject=(EditText) findViewById(R.id.emailsubject);
  19.         emailtext=(EditText) findViewById(R.id.emailtext);
  20.        
  21.         send.setOnClickListener(new OnClickListener() {
  22.                        
  23.                         @Override
  24.                         public void onClick(View v) {
  25.                                 // TODO Auto-generated method stub
  26.                                  
  27.                                       final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
  28.                                
  29.                                       emailIntent.setType("plain/text");
  30.                                  
  31.                                       emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{ address.getText().toString()});
  32.                                
  33.                                       emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject.getText());
  34.                                
  35.                                       emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, emailtext.getText());
  36.                        
  37.                                     Email.this.startActivity(Intent.createChooser(emailIntent, "Send mail..."));
  38.  
  39.                         }
  40.                 });
  41.     }
  42. }

It will use the button's onclicklistener method to send the email. It does not work on emulator, but works on real devices.

Comments

I do not real have a large deal to say in retort I just wanted to comment to tell well done. marvelous post. i never thought of that. John Simmons

bailey button triplet boots

ugg bailey button triplet

Thanks for sharing! I'm glad I was able to see these changes occurring on a regular basis. I think the email and application is a great idea! Christmas

Thank you so much for sharing a tutorial on how to send email from an application. I was very helpful at all. My permission to try it.

I am very happy to visit this site because a lot of science that I can get. An honor for me if you deign to visit my site: Meriahkan pesta ulang tahun bersama GarudaFood

nyt tag pris
This site is excellent and so is how the subject matter was explained. I also like some of the comments too.Waiting for next post.

I have got a really useful blog I have been here reading for about an hour. I am a newbie and your success is very much an inspiration for me........

spy text messages

We have a range from traditional white colored bridal gowns to other colors wedding dresses or perhaps a certain bridal gown made by your requirement. You'll really feel that you simply are wearing a pricey gown created specially for you, in the event you choose the wedding dresses from our store along with the dresses are mostly made of best top quality wedding fabrics like satin

wow your site have a bulk knowledge by the post and this is good for us.
lcd enclosure

Thank you - the site very very nice

المجتمع المصري هو مجتمع يحب الترفية حيث ان سكان مصر تصل الى تسعون مليون فرد ولذلك نحن نقدم خدمة دردشة مصرية لكل اهل مصر ام الدنيا , وتعتبر مصر متقدمة فى هذا العالم من حيث النمو فى مجالات التكنولوجيا و الكمبيوتر بنسبة كبيرة جدا لذلك نفضل دخول شات مصري اكبر تجمع بنات و شباب فى شات الحب و اجمل بنات فى دردشة دردشة الحب , اضافة الى ذلك حيث يوجد دردشة قوية تضم جميع محافظات مصر هي شات مصرية الكتابية نتمني لكم قضاء وقت ممكن فى شات الاصدقاء و احلي دردشة التعارف الذي يوجد به بنات رومانسية فى دردشة بنات مصر المصرية


شات الحب - دردشة مصرية - شات - شات مصري - شات حب - دردشة - دردشة كتابية - دردشة الحب - شات حبنا - شات حبي - شات مصرية - دردشة حب - شات بنات - دردشة مصر - دردشة بنات مصر - شات بنات مصر - شات صوتي - chat love - دردشة ياحبي - شات بنات لبنان - الحب - شات كتابي - منتدي ياحبي - شات مصر - دردشة حبنا - العاب تلبيس البنات - دردشة بنات - شات ياحبي - Chat - شات لبناني - شات كلامنجي - دردشة كلامنجي - شبكة - تصميم مواقع - تصميم - شات الاسكندرية - دردشة لبنانية - دردشة بنات لبنان - بنات لبنان - موقع شات - سعودي كول - شات سعودي كول - شات بنت مصر - شات سكس

Happy to see your blog as it is just what I’ve looking for and excited to read all the posts. I am looking forward to another great article from you. Jason Botlon // buy traffic

I have tried using this guide but I can't get it to work, like on step 37 where it says TextView what exactly does that command? And step 31 on the next page still boggles me. I found a possible explanation for this here: donez lucruri but I'm still not sure how that is going to work with the current version I am using and that is described here. Anyway if you find a good solution to this, please let me know. Thanks.

Good luck:)

These kind of articles are always attractive and I am happy to find so many good point here in the post writing is simply great thanks for sharing. Peter Bishop // Klangschale for each Chakra

I know there are many android based applications which have been widely used the self developed applications and additionals. I think the email features have been the standard features these days for many android based applications. ping online accounting

You really make it seem so easy with your presentation but I find this topic to be really something which I think I would never understand. It seems too complicated and very broad for me. I am looking forward for your next post.Outlet

I want to see whether or not government would be able to respond in such positive way. Finland's government has been well respond to this requirement by including this as one of the basic right for their people to have a good and fast internet access. Sleep Lab in Orange County

Many software developers have been enjoying the beauty of freedom that offered by many android based applications these days and should be well considered as the great commercial values attached to that. Miami plastic surgeon

I was very pleased to find this site. I wanted to thank you for this unique read. I definitely savoured all bits and pieces of it including all the comments and I have added you to my bookmark list to check out new articles you post. Jane Taylor // Photo Book

xmlns:android="http://schemas.android.com/apk/res/android"

android:orientation="vertical">

a b c d e f g h i j

=========================================================

ipad bag blog
Foods And Culinary Arts
short domain names

Nicely put and executed. Regarding websites for sale this article really gets down to the nitty-gritty. When it comes to websites for sale as in your excellent post, then turnkey websites or dropship websites simply take the cake. What enables you to buy a website or an online business is the very down-to-earth information given above.

so many candidates searching for work right now, how can you increase your chances of being the chosen candidate for the job that you want most chatroulette

The open source application like Android has certain flexibilities beyond what other system application has. I think this is what makes the android phone as the best application we can have in this world these days for our communication gadget. water bottle labels

I enjoyed reading your nice blog. I see you offer priceless info. Stumbled into this blog by chance but I'm sure glad I clicked on that link. You definitely answered all the questions I've been dying to answer for some time now. Will definitely come back for more of this. Scott Parsons / orjin krem pembe maske energy balance complex 41 nanomatik tütüne dur v-boom moliva Orjin yüz bakim Seti complex 41 tütüne son kibarli oyun tente sistemleri

Hey your site is really great I came across while in search for brand info on bing and it has lots of related information on it. Will be sure to come back again and bookmark. Keep up the great work! Bob Dickson // altbier langenfeld

I am sure many android based applications/gadget would expect to have this email function included in the standard package. Many manufacturers have adapted to this requirement and always included this feature in every device they make. Office Furniture

wow like this ahahha kaminomoto and this kaminomoto

the collegial atmosphere within and between departments. It is unclear where NYU plans to find the labor to replace the hundreds of teachers and graders who would not teach under this plan.Florida Dui Lawyer

I like to spend my free time by reading various internet recourses. Today I came across your blog and I found it is as one of the best free resources available! Well done! Keep on this quality! Paul Schrute // Friseur in Dresden

Your articles are full of helpful facts. Genuinely am appreciative for your help. I am glad I discovered this outstanding web page. Precisly what I needed to read. movie download

Free hug is something beyond what we can expect to see, but apparently he has been doing that for so long now and there seems no hesitation at all in him to do that wonderful thing to many people. significado dos sonhos

Woah this is just an insane amount of information must of taken ages to compile so thank you so much for just sharing it with all of us. If your ever in any need of related info perhaps a bit of coaching seduction techniques or just general tips just check out my own site! Pat Baker // Limpieza Madrid

Email function is one that has been always included in many android based application these days. I think this has somehow becomes the standard features in many android based devices/gadgets. How to sell my wedding gown

I like to spend my free time by reading various internet recourses. Today I came across your blog and I found it is as one of the best free resources available! Well done! Keep on this quality! Rupert Jones // cerrajeria barcelona

i just wanna thank you for sharing your information and your site or blog this is simple but nice article I've ever seen like it i learn something today... Jim Halbert // wirral martial arts

The post is very well written with lot of useful information for me. I am happy to find your great way of writing the post. With your generous help it is easier for me to understand and implement the concept. Thank you for the post.
limpieza Madrid

Email application is one of the most common application within android based application. I am sure this is something which has been the standard for many android application. With the easiness of android, things become more fun. Adventure Travel

A perfect info source. Thanks for taking the time to discuss this, I feel strongly about it and love learning more on this topic Dui lawyers

These kind of articles are always attractive and I am happy to find so many good point here in the post writing is simply great thanks for sharing. John Garnick // Buy 5-APB

Sending an email through an android email application can’t be more easier than this. Android has given us so much chances to be able to set-up the sending email mechanism as we want it and the way we want it. This is the beauty of open source application. baby favors

I could be one of the people who has been blessed with such knowledge on how to deal with Android without even have formal education and training on this subject. Internet has been the only source for me to learn this new application platform. www.top20datingwebsites.com

Easily the post is really the greatest on this laudable topic. I concur with your conclusions and will thirstily look forward to your future updates. Saying thanks will not just be sufficient for the fantastic c lucidity in your writing. I will instantly grab your rss feed to stay privy of any updates. Solid work and much success in your business enterprise! Alan Maddison // replacement number plates

Nice blog having nice information. some times we ignore this sort of things & also suffer a lot as well. However we can save a lot with the assistance of these tips for example time etc.

FHA Loans

I want to take part proactively in promoting the usage of android based applications. There are many things we can do to improve the quality, and users feedback is the good source for the purpose. food service equipment

Anything designed according to the users needs and comfort works greatly and has wide acceptance. Your is a nice idea in this regard. It is innovative and creative in nature. Jack Johanson // south of france property

I realise this is off topic but while your blog looks nice it would be far better if you'll be able to use lighter colors too in the design. This will encourage a lot more readers come to check it out more often!
Peter, from bolts nuts fasteners

Thanks for making such a killer blog. I arrive on here all the time and am floored with the fresh information here! You are great! John Walker // psicologo rivas

I think it's great that you guys are paving the way for the android. I hope to see the day when open source software leads the market and end user's will rid themselves of such high prices. I also expect free online applications like Baseball Games Online and extreme sports like Football Games Online to be available as well.

wow this a nice bro kaminomoto

I want to see what I can do in this android based application tutorial generator. I want to contribute with my own capacity in this area. There should be good support from the application developers themselves too. IWC