Show me the code! – By Davanum Srinivas

December 22, 2007

Android – Send email via GMail (actually via SMTP)

Filed under: Uncategorized — Davanum Srinivas @ 11:10 pm

Here is a screen shot.


The main activity is pretty simple


import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class SendMail extends Activity {
     * Called with the activity is first created.
    public void onCreate(Bundle icicle) {
        final Button send = (Button) this.findViewById(;
        final EditText userid = (EditText) this.findViewById(;
        final EditText password = (EditText) this.findViewById(;
        final EditText from = (EditText) this.findViewById(;
        final EditText to = (EditText) this.findViewById(;
        final EditText subject = (EditText) this.findViewById(;
        final EditText body = (EditText) this.findViewById(;
        send.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                GMailSender sender = new GMailSender(userid.getText().toString(), password.getText().toString());
                try {
                } catch (Exception e) {
                    Log.e("SendMail", e.getMessage(), e);

The GMail Sender code is from here


import javax.activation.DataHandler;
import javax.activation.DataSource;
import javax.mail.Message;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import java.util.Properties;

public class GMailSender extends javax.mail.Authenticator {
    private String mailhost = "";
    private String user;
    private String password;
    private Session session;

    static {
        Security.addProvider(new org.apache.harmony.xnet.provider.jsse.JSSEProvider());

    public GMailSender(String user, String password) {
        this.user = user;
        this.password = password;

        Properties props = new Properties();
        props.setProperty("mail.transport.protocol", "smtp");
        props.setProperty("", mailhost);
        props.put("mail.smtp.auth", "true");
        props.put("mail.smtp.port", "465");
        props.put("mail.smtp.socketFactory.port", "465");
        props.put("mail.smtp.socketFactory.fallback", "false");
        props.setProperty("mail.smtp.quitwait", "false");

        session = Session.getDefaultInstance(props, this);

    protected PasswordAuthentication getPasswordAuthentication() {
        return new PasswordAuthentication(user, password);

    public synchronized void sendMail(String subject, String body, String sender, String recipients) throws Exception {
        MimeMessage message = new MimeMessage(session);
        DataHandler handler = new DataHandler(new ByteArrayDataSource(body.getBytes(), "text/plain"));
        message.setSender(new InternetAddress(sender));
        if (recipients.indexOf(',') > 0)
            message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(recipients));
            message.setRecipient(Message.RecipientType.TO, new InternetAddress(recipients));

    public class ByteArrayDataSource implements DataSource {
        private byte[] data;
        private String type;

        public ByteArrayDataSource(byte[] data, String type) {
   = data;
            this.type = type;

        public ByteArrayDataSource(byte[] data) {
   = data;

        public void setType(String type) {
            this.type = type;

        public String getContentType() {
            if (type == null)
                return "application/octet-stream";
                return type;

        public InputStream getInputStream() throws IOException {
            return new ByteArrayInputStream(data);

        public String getName() {
            return "ByteArrayDataSource";

        public OutputStream getOutputStream() throws IOException {
            throw new IOException("Not Supported");


  • We use activation-1.1.jar and mail-1.4.jar from SUN

  • Picked up a few classes in java.awt.datatransfer package from Apache Harmony SVN (and stripped them down)

  • Picked up the ByteArrayDataSource class from Apache Axis

  • build.xml adds the 2 jars and the additional harmony/axis classes into the classes.dex as well

Download Source and APK from here –


  1. Thanks so much!

    Comment by shiyansucks — December 23, 2007 @ 12:09 am

  2. […] Envoyer un message GMail avec Android. Davanum a encore frappé ! […]

    Pingback by Android en vrac de Noël ! — December 23, 2007 @ 6:03 pm

  3. Cool app.

    Comment by Android App — December 24, 2007 @ 4:32 pm

  4. Thank you so much!!!

    You have a prosperous new year 2008!!!

    Comment by Peter — January 6, 2008 @ 11:17 pm

    • hi peter,

      if u have source code for sendmail ,plz mail me the source code.
      the link in web site is not working.

      thankq for ur time.

      my mail

      Comment by Rajasekhar — January 9, 2010 @ 2:45 am

  5. Awesome!!!

    Comment by Russian Translit — January 10, 2008 @ 8:51 pm

  6. i am getting the following error:

    E/AndroidRuntime(685): … 19 more
    E/AndroidRuntime(956): Uncaught handler: thread Main exiting due to uncaught exception
    E/AndroidRuntime(956): java.lang.NoClassDefFoundError: javax/activation/DataHandler
    E/AndroidRuntime(956): at
    E/AndroidRuntime(956): at$1.onClick(
    E/AndroidRuntime(956): at android.view.View.performClick(
    E/AndroidRuntime(956): at android.widget.Button.performClick(
    E/AndroidRuntime(956): at android.widget.TextView.onKeyDown(
    E/AndroidRuntime(956): at android.view.KeyEvent.dispatch(
    E/AndroidRuntime(956): at android.view.View.dispatchKeyEvent(
    E/AndroidRuntime(956): at android.view.ViewGroup.dispatchKeyEvent(
    E/AndroidRuntime(956): at android.view.ViewGroup.dispatchKeyEvent(
    E/AndroidRuntime(956): at android.view.ViewGroup.dispatchKeyEvent(
    E/AndroidRuntime(956): at android.view.ViewGroup.dispatchKeyEvent(
    E/AndroidRuntime(956): at android.policy.PhoneWindow$DecorView.superDispatchKeyEvent(
    E/AndroidRuntime(956): at android.policy.PhoneWindow.superDispatchKeyEvent(
    E/AndroidRuntime(956): at
    E/AndroidRuntime(956): at android.policy.PhoneWindow$DecorView.dispatchKeyEvent(
    E/AndroidRuntime(956): at android.view.ViewRoot.handleMessage(
    E/AndroidRuntime(956): at android.os.Handler.dispatchMessage(
    E/AndroidRuntime(956): at android.os.Looper.loop(
    E/AndroidRuntime(956): at
    E/AndroidRuntime(956): at java.lang.reflect.Method.invokeNative(Native Method)
    E/AndroidRuntime(956): at java.lang.reflect.Method.invoke(
    E/AndroidRuntime(956): at android.os.ZygoteInit$
    E/AndroidRuntime(956): at android.os.ZygoteInit.main(
    E/AndroidRuntime(956): at android.dalvik.NativeStart.main(Native Method)
    E/AndroidRuntime(956): Caused by: java.lang.ClassNotFoundException: javax.activation.DataHandler in loader$PathClassLoader@4008a2c8
    E/AndroidRuntime(956): at$PathClassLoader.findClass(
    E/AndroidRuntime(956): at java.lang.ClassLoader.loadClass(
    E/AndroidRuntime(956): at java.lang.ClassLoader.loadClass(
    E/AndroidRuntime(956): … 24 more
    ,i added the jars you provided in the zip….

    Comment by csagar — January 26, 2008 @ 4:12 am

    • im getting the same error………
      have you got the solution?
      if yes then pls rpl me.

      Comment by Chirag Shah — October 31, 2011 @ 4:43 am

      • thats because of Toast,UI commands cannot use in thread, you must use Async Tasks instead Threads

        Comment by Hossein — September 18, 2015 @ 11:22 am

  7. when i downloaded the zip i got /java/awt/datatransfer package also… i am not using your build file…so ,is it required ??? i get no error on comiplation.I checked your build.xml. You have mentioned in the notes that build.xml adds two jars.and some harmony/axis class .i could found the jars.but not these classes. Whats going wrong in my case??please reply

    Comment by csagar — January 26, 2008 @ 4:39 am

  8. thanks , it was a great help for me, i am trying to make a mail client including sending and receiving mails

    Comment by shimul — January 28, 2008 @ 2:56 am

  9. how to connect the smtp server

    Comment by kmk — February 6, 2008 @ 6:03 am

  10. Very useful program. I am programming aplication, where i need to send email with attachement. Does enybody know haow to do that? I tried this with multipart and bod part stuff like you can do that in java, but it doesn’t work here in android. I get no errors but I get either no email to may inbox which I had sent with android.

    Does somebody have any suggestions? Where is the problem?

    Please help me…


    Comment by marko — February 6, 2008 @ 7:07 am

  11. Great post, that helped me to get started with imap on Android:

    Comment by Toni Epple — February 10, 2008 @ 11:34 am

  12. This is suporting html email
    How can i enable html email in Amdorid

    Comment by hari — February 11, 2008 @ 12:52 pm

  13. And I should add: Awesome! Thanks 🙂

    Comment by Joseph Dung — February 12, 2008 @ 8:03 am

  14. Great work… but has anyone gotten attachments to work with this? It sends the email fine but no attachments get through.


    Comment by George — February 20, 2008 @ 10:43 am

    • hello

      for it is working , for me i didn’t got any errors but it shows exception unablle to connect to smtp mail and session time out exception and one more exception nested exception

      i did this in emulator

      Comment by ram — December 15, 2010 @ 3:50 am

  15. Hi,

    I copied the code above into my android program using Eclipse, and the code didn’t have any compilation problem. However, when I run it, I get the following error message:

    java.lang.NoClassDefFoundError: javax/activation/DataHandler

    I have both the activation-1.1.jar and mail-1.4.jar in my build path. Can someone help me out? I have been trying to solve this for one week already. Thanks!

    Comment by mcluucy — March 15, 2008 @ 12:16 am

    • hey did u find the solution for this problem coz i am also stuck wid this problem for 3-4 days!
      Thanks in anticipation!

      Comment by Sahil.hariram — June 11, 2010 @ 3:38 am

  16. i am getting java.lang.NoClassDefFoundError execption… Can anyone help me out…

    Comment by nithin — April 1, 2008 @ 6:02 am

    • hey did u find the solution of dis prob!
      Thanks u in anticipation!

      Comment by sahil.hariram — June 11, 2010 @ 3:40 am

  17. hello sir
    I would to ask how to run this application under eclipse environment

    Comment by miladi — April 8, 2008 @ 6:40 am

  18. I can run its on eclipse.
    I build new project and copy all source file to project.
    after that you can not run it. Because name of activity(start activity) does not match. So I change Activity class name to match with name of start activity in open dialog.

    Comment by RoSippA — May 6, 2008 @ 1:19 am

  19. mcluucy (and others):

    The NoClassDefFoundError results from android’s lack of java.awt.datatransfer classes. In order to gain access to message contents in javamail (sending or receiving) you need to have the DataHandler class that is in activation.jar; however, this class will fail to link if specific classes from java.awt.datatransfer are not present. Hence, the error messages indicate that DataHandler cannot be loaded, even though it is in the classpath.

    The provided .zip contains (as indicated in the notes after the above source code) a few files from the Apache Harmony implementation of java (presumably cut to remove compilation errors), which can be copied into a project. However, note that if you indend to use these files to gain read access to a MimeMessage (e.g., IMAP client), I’ve found that they only provide an InputStream, and do not allow you to cast .getContent as a String or Multipart. I imagine the relevant awt classes required for these DataHandlers can be similarly acquired.

    Comment by Will — May 8, 2008 @ 3:59 am

  20. Also, note that an implementation of ByteArrayDataSource was taken from Apache Axis to define the DataHandler required to send the mail (as shown in the above source code). A similar technique may be useful in retrieving a String or Mailpart with .getContent()

    Comment by Will — May 8, 2008 @ 4:21 am

  21. i am getting a number format exception when i set my mail.smtp.port to the ip as below.
    ERROR/GmailSender SendMail()(849): java.lang.NumberFormatException:

    Comment by farah — May 15, 2008 @ 9:01 am

  22. I discovered (a while ago, but forgot to post a comment here) the cause to the .getContent() error described above. When the activation.jar and mail.jar archives are imported into Android, the META-INF directories containing the mailcap entries are stripped. When the classes look at the MIME type on the content, it doesn’t find a known handler because one is never defined.

    Comment by Will — June 1, 2008 @ 7:13 pm

  23. Hi,
    The is not downloadable. I too had the same problem java.lang.NoClassDefFoundError: javax/activation/DataHandler. Please help.


    Comment by Sathiya — August 22, 2008 @ 11:49 am

  24. Get nothing from the download link.
    I would love to know the extra classes I need…

    Comment by elvis — August 26, 2008 @ 5:33 am

  25. sir where we get this import; packet

    Comment by Ruby — September 16, 2008 @ 4:55 am

  26. Tried downloading the code, but it was unavailable.

    Comment by Mirko — October 1, 2008 @ 12:36 am

  27. The Zip is no longer on your server… Is it on purpose ?
    Please put it back.

    Comment by Majax — October 10, 2008 @ 7:48 pm

  28. hi
    very nice code but it is uncomplete
    i mean many qustion are unanswered
    you not told
    how to add two jar file?
    how i create or download these two package java.awt.datatransfer package and
    what is this?
    build.xml adds the 2 jars and the additional harmony/axis classes into the classes.dex as well

    plz tel me how to do all these setting
    Thank You

    Comment by RAHUL — January 6, 2009 @ 6:29 am

  29. Hi,

    I would also like the zip file. I’ve been trying to compile myself but with no joy. It would be a great help if you could reupload.

    Thank you,

    Comment by Chiggsy — February 8, 2009 @ 8:22 am

  30. Hello webmaster
    I would like to share with you a link to your site
    write me here

    Comment by Alexwebmaster — March 3, 2009 @ 3:19 am

  31. can any1 send me the zip file please. i cant download the zip project.this is my email

    Comment by saifuctg — April 2, 2009 @ 4:14 pm

  32. I can’t see how this code works, when I run, both on the device or emulator it fails with a java.lang.VerifyError This is because javax.mail depends on javax.activation package. The DataHandler class in activation uses an interface from awt which is obviously not included in the dalvik system.

    Before the exception is thrown I see

    Failed resolving Ljavax/activation/DataHandler; interface 178 ‘Ljava/awt/datatransfer/Transferable;’

    So, how do you get javax.mail to run without this dependency?

    Comment by John Hunsley — April 6, 2009 @ 4:59 am

  33. Hello everyone,
    I am looking for a way to download the zip file.
    If any of you have it, please email me at


    Comment by Noam — April 7, 2009 @ 11:39 am

  34. download from here

    if u got any question. don’t send me private email plz.

    Comment by saifuctg — April 9, 2009 @ 6:25 pm

  35. I have download the code. And compile it without error. But when I run it, it crash down. I doubt if the imported lib can run on android platform.

    Comment by cyber — April 20, 2009 @ 3:22 am

  36. There is obviously a lot to know about this. I think you made some good points in Features also.

    Comment by Lilian Waldridge — April 27, 2009 @ 10:30 am

  37. 1 more good solution is coming guys….wait few days let me finish my exams.

    Comment by saifuctg — May 6, 2009 @ 5:41 pm

  38. […] another attempt at putting together bits and pieces with more details how to go about this yourself but it’s really lots of hacking which most people might like to avoid. Someone else has also […]

    Pingback by How to Send an Email « Android Software Developer — May 15, 2009 @ 10:58 am

  39. Hey saifuctg thanks for the SendMail rar, it doesnt seem to be complete though…its missing the extra harmony/axis classes that are supposed to be added to the dex file….dont suppose anyone still has a copy of them lying around anywhere?

    -James (

    Comment by james grafton — May 28, 2009 @ 12:56 pm

    • Hey guys managed to get this working on 1.5 and 1.1 firmware. unfortunately it ended up not being very useful for me (I wanted to use gmail as a mail relay – unfortunately Google overwrites the From header whenever you send a mail from an authenticated account)…

      Anyways you guys might still find a use for it. I have created two jar files, additional.jar contains the missing datatransfer classes and custom_activation.jar is a customized set of activation classes which reference the local data transfer classes rather than the system default ones.

      You can find both of these jar files at:


      Comment by james grafton — June 2, 2009 @ 4:27 am

  40. Hello, I have this error
    java.lang.VerifyError: javax.mail.internet.MimeMessage
    Any idea to fix it?
    Thanks anyway!

    Comment by markuz — June 2, 2009 @ 11:59 am

    • Hi,

      “Ljavax/activation/DataHandler” problem is still observed. can anybody give any suggesion to solve this problem. whether the new .jar files (custom_activation, additional.jar) will solve this issue.

      can you attach those .jar files again. only

      Comment by Nayan — June 3, 2009 @ 1:59 am

  41. Hi Mark, how exactly are you trying to use the libraries? could you post the code snippet thats actually throwing that exception?

    My initial thoughts are that your using a corrupt version of mail.jar…try using the one on my site (

    Comment by james grafton — June 3, 2009 @ 4:21 am

  42. Hi,
    I met with the problem by the statement:
    MimeMessage message = new MimeMessage(session);
    Please kindly help.
    Thank you in advance,

    Comment by Ohyes — July 10, 2009 @ 1:25 am

  43. i do whatever i must but It is not working correctly.

    Comment by Luis — July 16, 2009 @ 6:40 am

  44. Does not work, Android is missing the necessary AWT classes javax.activation depends on. Alternatively the commons net library can be used with a patch:

    Comment by soniq — August 23, 2009 @ 11:30 am

  45. […] There’s another attempt at putting together bits and pieces with more details how to go about this yourself but it’s really lots of hacking which most people might like to avoid. Someone else has also claimed to port gnu inetlib. […]

    Pingback by How to Send an Email - MSINO | Mobile Sino — August 31, 2009 @ 7:26 am

  46. […] the original post here: Android – Send email via GMail (actually via SMTP) « Show me the … Share and […]

    Pingback by Android – Send email via GMail (actually via SMTP) « Show me the … | Android Operating System — September 12, 2009 @ 12:58 am

  47. […] more here: Android – Send email via GMail (actually via SMTP) « Show me the … Share and […]

    Pingback by Android – Send email via GMail (actually via SMTP) « Show me the … | Android Operating System — September 12, 2009 @ 12:59 am

  48. If any one has complete then please send that to me.

    Comment by Sachin — September 17, 2009 @ 1:34 am

    • please send it ASAP

      Comment by Sachin — September 30, 2009 @ 6:22 am

  49. Thank you!

    Comment by RR — September 25, 2009 @ 9:48 am

  50. If any one has complete then please send that to me at

    Comment by Sachin — October 9, 2009 @ 3:03 am

  51. I have this problem:
    “Ignoring InnerClasses attribute for an anonymous inner class that doesn’t come with an associated EnclosingMethod attribute. (This class was probably produced by a broken compiler.)”
    If any one has this problem please leave a message here, we can try to solve this problem together.

    Comment by Richard — November 11, 2009 @ 9:37 am

  52. I cannot UNDERSTAND why people don’t answer the questions.
    When i check in my email, i there’s a new message i always answer the question.
    I leave my email address in this forum. I anypeople want solve the problem of this code can contact me.
    I’m trying to solve this problem.
    Good work.

    Comment by Richard — November 14, 2009 @ 12:18 pm

  53. The is not openeing if u have code please give me.

    my mail id is

    Thanks in Advance


    Comment by slashgill — December 1, 2009 @ 4:17 am

  54. finally got it working with files provided here:

    take a look…

    Comment by Djo — January 5, 2010 @ 9:46 pm

  55. Please send the to
    M getting errors when i tryout with this code might be something is missing.

    Comment by Vinayak — January 8, 2010 @ 2:03 am

  56. if any one have running “Source Code” and “APK” ( Please Send me at

    Comment by Dheeresh — January 14, 2010 @ 4:03 pm

    • hi… can u send me ur piece of code it will a gr8 help for me…. thanks in advance

      Comment by mohit lohiya — September 5, 2011 @ 6:17 am

  57. Hello, this is awesome. Exactly what I’m looking for.

    The javamil and activation jars i got from SUN didn’t work in my android project so I got modified files from

    However my only problem with the code now is the:

    Security.addProvider(new org.apache.harmony.xnet.provider.jsse.JSSEProvider());

    line. What do I have to do to fix this?


    Comment by Raffe — January 18, 2010 @ 5:52 am

    • hey did u find the solution for this problem bcoz i am also stuck wid this problem for 3-4 days!
      Thanks in anticipation! if u find plz send code to my mail

      Comment by Noor — April 12, 2012 @ 1:02 am

  58. Hii Thanx Lot ….

    Can u Please Show me How I can receive Mail Using Imap/Pop3 in Androide…..

    I work with SMS Receive App where I use BroadCastReceiver Successfully..But here it’s not working

    Do needful
    Thnxa in Advance

    Comment by shubham — March 3, 2010 @ 9:28 am

  59. hi ,
    not working for me.shows hello world ,send mail on emulator.but no mail is sent. 😦 what is wrong in my set up? how can i get that?

    Comment by rashmi — March 4, 2010 @ 6:00 am

  60. Hi Srinivas,

    I read your article on Sending an email on Anrdoid.
    The link you provided for doesn’t work. Could you please update the link or send me via Thank you.

    Comment by Krishna — March 25, 2010 @ 7:32 pm

  61. […] sends an email programmatically without user intervention. It is based on the excellent article at (many thanks davanum!) You need to use a valid gmail account id and its password. The real trick is […]

    Pingback by zxhwolfe的开发点滴 » send email without user intervention — June 22, 2010 @ 2:54 am

  62. Hi everyone!
    It doesn’t run. If anyone have been done, please send me via
    Thanks so much

    Comment by Nguyen — June 26, 2010 @ 6:11 am

  63. Hi everyone!

    Please send me the code at

    Comment by Jawwad — September 2, 2010 @ 2:04 am

  64. Best you could edit the blog name title Android – Send email via GMail (actually via SMTP) Show me the code! – By Davanum Srinivas to more catching for your content you make. I enjoyed the the writing nevertheless.

    Comment by Player Profiles — October 30, 2010 @ 2:21 am

  65. Hi this seems important to me..
    Can you plz send email me source code

    Comment by dhara — December 16, 2010 @ 8:10 am

  66. I couldn’t download the zip file… Pls send the code at

    Comment by Selvam — December 27, 2010 @ 8:35 am

  67. The link for the zip file isn’t working.
    Please send me the zip file at

    Comment by Sahil Midha — June 11, 2011 @ 7:13 am

  68. How to Send Bulk email using above example?

    Comment by Dipak Keshariya — June 28, 2011 @ 2:52 am

  69. hi

    The is not openeing if u have code please give me.
    my mail id is

    Comment by indela — July 22, 2011 @ 5:36 am

  70. Hi everyone..
    I’ve implemented the application (of sending the attachment with our own mail sender.) quite successfully.
    Attachment is sent is shown in the account also. But the problem is that the file name changes to noname.
    I sent one jpg file. When i try to open it from my gmail account, It shows msg-“no preview is available”.
    So i just try to open it from notepad(It seems to be a stupid activity but its an experiment not a stupidity).
    Then I found that whatever i write in the email body is there in that Jpg file.

    So please do help me out..
    Thank u…

    Comment by Atul Sonawale — August 17, 2011 @ 12:27 am

  71. Hi, all ^^
    i practice this but don’t work…

    please help me…

    error: java.awt.datatransfer (Android SDK doesn’t have this class!!)

    even if i import all .jar file… it can’t work…

    does anyone could send me the full code? (


    Comment by alicelai91 — September 2, 2011 @ 5:41 am

  72. hi i am trying to download the SendMail.Zip… but its not working….can any1 send me the code and ByteArrayDataSource class from Apache Axis on……

    Comment by mohit lohiya — September 5, 2011 @ 6:15 am

  73. im getting this error:

    10-31 14:20:29.385: ERROR/AndroidRuntime(615): FATAL EXCEPTION: main
    10-31 14:20:29.385: ERROR/AndroidRuntime(615): java.lang.NoClassDefFoundError: javax.activation.DataHandler
    10-31 14:20:29.385: ERROR/AndroidRuntime(615): at com.test.GMailSender.sendMail(
    10-31 14:20:29.385: ERROR/AndroidRuntime(615): at com.test.SendMail$1.onClick(
    10-31 14:20:29.385: ERROR/AndroidRuntime(615): at android.view.View.performClick(
    10-31 14:20:29.385: ERROR/AndroidRuntime(615): at android.view.View$
    10-31 14:20:29.385: ERROR/AndroidRuntime(615): at android.os.Handler.handleCallback(
    10-31 14:20:29.385: ERROR/AndroidRuntime(615): at android.os.Handler.dispatchMessage(
    10-31 14:20:29.385: ERROR/AndroidRuntime(615): at android.os.Looper.loop(
    10-31 14:20:29.385: ERROR/AndroidRuntime(615): at
    10-31 14:20:29.385: ERROR/AndroidRuntime(615): at java.lang.reflect.Method.invokeNative(Native Method)
    10-31 14:20:29.385: ERROR/AndroidRuntime(615): at java.lang.reflect.Method.invoke(
    10-31 14:20:29.385: ERROR/AndroidRuntime(615): at$
    10-31 14:20:29.385: ERROR/AndroidRuntime(615): at
    10-31 14:20:29.385: ERROR/AndroidRuntime(615): at dalvik.system.NativeStart.main(Native Method)

    Comment by Chirag Shah — October 31, 2011 @ 3:58 am

  74. Can you plz send me zip file of
    Its urgent for me….

    Comment by Manan — November 11, 2011 @ 11:55 am

  75. send zip on
    Its urgent

    Comment by Manan — November 11, 2011 @ 11:56 am

  76. Thank you. could you please mail me the zip file and apk file

    Comment by Bhavya — December 5, 2011 @ 12:34 am

  77. Thank you. could you please mail me the zip file and apk file to

    Comment by Bhavya — December 5, 2011 @ 12:36 am

  78. Thank you. could you please mail me the zip file and apk file to

    Comment by Bhavya — December 5, 2011 @ 12:37 am

  79. I think setFrom is true, not setSender.
    I have a question, how to disconnect SMTP when finish send email. Because when i login again with another account, i get a account before, not current for sending email. ( see in the email box ).

    Comment by le quoc tuan — February 29, 2012 @ 11:48 am

  80. Thank you. could you please mail me the zip file and apk file to

    Comment by Perumal — May 25, 2012 @ 1:56 am

  81. can any1 send me the zip file please. i cant download the zip project.this is my email

    Comment by adnane — June 7, 2012 @ 9:46 am

  82. org.apache.harmony.xnet.provider.jsse.JSSEProvider() causes error

    Comment by sunil pal — August 9, 2012 @ 4:03 am

  83. request time failed: Address family not supported by protocol

    i get this error please help me..


    Comment by dhaval patel — August 23, 2012 @ 6:51 am

  84. You can make some changes to send email with subject, body and more than 1 file attached…

    This is how:

    First copy add the 3 jar files to your project (activation.jar, additionnal.jar and mail.jar)

    Then, you create the 2 classes and

    Replace the method sendMail for this one

    public synchronized void sendMail(String subject, String body, String sender, String recipients, String[] filenames) throws Exception {
    MimeMultipart _multipart = new MimeMultipart();
    MimeMessage message = new MimeMessage(session);

    // fill recipients

    if (recipients.indexOf(‘,’) > 0)
    message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(recipients));
    message.setRecipient(Message.RecipientType.TO, new InternetAddress(recipients));

    message.setSender(new InternetAddress(sender));


    if ( filenames.length > 0 )
    for ( String filename : filenames)
    BodyPart messageAttach= new MimeBodyPart();

    DataSource source = new FileDataSource(filename);
    messageAttach.setDataHandler(new DataHandler(source));

    // fill body

    BodyPart messageBody= new MimeBodyPart();


    }catch(Exception e){


    and its done….

    Comment by Developer Tuga — September 25, 2012 @ 8:58 am

  85. hi,
    the link for the code source is not working, plz mail it to me

    Comment by Farouk — April 28, 2013 @ 9:39 am

  86. i can’t download file zip . Please send me the code at

    Comment by Hihi — May 7, 2013 @ 10:14 pm

  87. Hello, thanks for the code. I have a problem. I have compile and every thing works, but when I click send, it sends but I never see the mail in my box

    Comment by Nester Mike — June 16, 2013 @ 8:30 am

  88. Can you please Mail me code of to
    Thank You in advance.

    Comment by Raj — December 18, 2014 @ 1:35 am

  89. dear in download link no source code is avaiable plz somebody send me source code and apk file i much needed right now plz

    Comment by sohail37 — November 17, 2015 @ 12:30 pm

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Blog at

%d bloggers like this: