• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Sending an Email with JavaMail

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello everyone,
I have imported the JavaMail class into my application with the .jar file found here:
http://www.java2s.com/Code/Jar/wsit/Downloadmail14jar.htm

I would like to find a way to send an email using the JavaMail class.

I have unsuccessfully tried this link:
http://davanum.wordpress.com/2007/12/22/android-send-email-via-gmail-actually-via-smtp/

I've also tried this code:



The problem with it is that it requires the user to pick an email client, and then the user has to send it manually. I want it to send automatically, without notifying the user that the email was sent.

Does anyone have any suggestions?

Thanks,
Noam.
 
Noam Habot
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have just found out that the new android sdk is not compatible with the JavaMail external .jar.
Is there a workaround for this? Is there a way to still get it to work?

Thanks,
Noam.
 
Ranch Hand
Posts: 215
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Hi,

Use Java Mail API. This is the standard while working on mail things in Java. Download this API, you will see two jar files in lib activation.jar and another mail.jar (I am not sure about the name for mail.jar). Keep these two jars in classpath and use API.
Everytime prefer to use API which is standard.

Let me know if you get the problem,
 
Noam Habot
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your answer.
I have tried that, and when I import the external library into my application, it tells me:

[2009-04-08 13:49:56 - MyApp] warning: 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.)

Noam.
 
Rahul Ba
Ranch Hand
Posts: 215
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Somethig weired....try reinstalling jdk, your IDE
 
Noam Habot
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have tried all that but it still didn't work.
Did you ever get it to work?
If so, what android sdk version did you use?
And if you used 1.0+, then could you please put up some code here that we can take a look at?

Thanks,
Noam.
 
Rahul Ba
Ranch Hand
Posts: 215
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have not worked on Android, but you will get similar code in java on net. There are many samples available on net.
 
Noam Habot
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's the problem.
It seems that with Android, the JavaMail class does not work.
 
Ranch Hand
Posts: 136
Android Mac Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Noam,

Have you find out the way to send Email with any API from emulator? I tried it with K-9(that was an APK file), but as you mentioned earlier it provides its own GUI to send email when i use intent, user have to send it manually. I tried with Java Mail API also, but no success at all. Please let us know whenever you get the way.

Thanks & Regards
Pratik Goswami
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Pratik Goswami wrote:Hi Noam,

Have you find out the way to send Email with any API from emulator? I tried it with K-9(that was an APK file), but as you mentioned earlier it provides its own GUI to send email when i use intent, user have to send it manually. I tried with Java Mail API also, but no success at all. Please let us know whenever you get the way.

Thanks & Regards
Pratik Goswami



Hi Pratik and anybody else,

try this: http://nilvec.com/sending-email-without-user-interaction-in-android/

It also explains why Java Mail is not an option for Android.

Regards,
Joska
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Noam Habot wrote:Hello everyone,
I have imported the JavaMail class into my application with the .jar file found here:
http://www.java2s.com/Code/Jar/wsit/Downloadmail14jar.htm

I would like to find a way to send an email using the JavaMail class.

I have unsuccessfully tried this link:
http://davanum.wordpress.com/2007/12/22/android-send-email-via-gmail-actually-via-smtp/


Thanks,
Noam.



javamail.jar can't be used in android. Some classes those are not belong to android sdk were imported in the jar .So you have to clean up javamail.jar.


Regards,
Steven
 
Steven WangXiangJun
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Finally I find the way to send emails on android via javamail.
click Here:http://code.google.com/p/javamail-android/downloads/list

Now,everything is ok!


Steven
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
After searching far and wide for a solution to this .. with the ability to add attachments .. I came across this (and it works!):

[SOLUTION]: http://www.jondev.net/articles/Sending_Emails_without_User_Intervention_%28no_Intents%29_in_Android
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic