Send Email Automatically

by Noam » Tue, 07 Apr 2009 06:47:20 GMT


Sponsored Links
 Hello everyone,
I am looking for a way to send an email from a DEFINED email to the
user's email. I will also have a defined subject and a defined email -
body.

My situation is that when the user forgets his password, he needs to
enter in his email into the text box and then the application will
automatically send an email to his mailbox.

Is there any way to do this without the user getting his mail client
popping up?

Thanks,
Noam.
--~--~---------~--~----~------------~-------~--~----~



Send Email Automatically

by Mark Murphy » Tue, 07 Apr 2009 09:03:40 GMT


 


What text box?


What application? Running where?


What mailbox?


What mail client?

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com  |  http://twitter.com/commonsguy 

Warescription: Three Android Books, Plus Updates, $35/Year

--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


Send Email Automatically

by Noam » Tue, 07 Apr 2009 10:14:28 GMT


 > What text box?

Scratch that out. Let's just say that I have the user's email address
in a String named "userEmail".


It is actually a dialog box that when he presses send, it will send an
email to his mailbox.


The user's personal email address. For example noam.ha...@gmail.com


Every time I try to send an email with my code,
1) The "To: " field does not get populated.
2) The mail client pops up with the "To: , Subject, and Body" fields
and a "send" button. However, I want the email to be sent
automatically, without having to go through the mail UI.

My code:

// Setup the recipient in a String array
String[] mailto = {"noam.ha...@gmail.com"};
// Create a new Intent to send messages
Intent sendIntent = new Intent(Intent.ACTION_SEND);
//Write the body of the Email
String emailBody = "You're password is: ";
// Add attributes to the intent
sendIntent.setType("text/plain"); //use this line for testing in the
emulator
//sendIntent.setType("message/rfc822"); //use this line for testing on
the real phone
sendIntent.putExtra(Intent.EXTRA_EMAIL, mailto);
sendIntent.putExtra(Intent.EXTRA_SUBJECT, "Your Password");
sendIntent.putExtra(Intent.EXTRA_TEXT, emailBody);
startActivity(Intent.createChooser(sendIntent, "Please pick your
preferred email application."));


The address which will send this email is pre-defined.

Thanks,
Noam.
--~--~---------~--~----~------------~-------~--~----~



Send Email Automatically

by Mark Murphy » Tue, 07 Apr 2009 18:13:29 GMT


 


You will need to write your own SMTP client (perhaps using some
third-party JAR).

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com  |  http://twitter.com/commonsguy 

Warescription: Three Android Books, Plus Updates, $35/Year

--~--~---------~--~----~------------~-------~--~----~



Send Email Automatically

by Noam » Tue, 07 Apr 2009 22:26:49 GMT


 Would you know where I could find one of those?

Thanks,
Noam.
--~--~---------~--~----~------------~-------~--~----~



Send Email Automatically

by Noam » Tue, 07 Apr 2009 22:51:54 GMT


 Would these three links help me in any way? Maybe I can use IMAP
instead of SMTP (I don't know the differences)? And how can I use each
class?

 http://www.java2s.com/Code/Jar/wsit/Downloadmail14jar.htm 
 http://www.java2s.com/Code/Jar/Web-Services-AXIS2/Downloadactivation11jar.htm 
 http://eppleton.sharedhost.de/blog/?p=176 

Thanks,
Noam.
--~--~---------~--~----~------------~-------~--~----~



Send Email Automatically

by mikas » Wed, 08 Apr 2009 02:00:15 GMT


 I was having problems with this code and eventually found out
that newer version of android sdk will not allow you to use those
external libraries....

on the other hand, keep on digging.... :)



--~--~---------~--~----~------------~-------~--~----~



Send Email Automatically

by Noam » Wed, 08 Apr 2009 02:03:13 GMT


 I have used the mail 1.4 jar, and installed it successfully.
Even though I tried multiple examples, none of them seem to work.
All I get, when I look at the logcat, is

Uncaught handler: thread main exiting due to uncaught exception
 java.lang.VerifyError: javax.mail.internet.MimeMessage

I have tried all of these examples:

 http://www.rgagnon.com/javadetails/java-0321.html 
 http://davanum.wordpress.com/2007/12/22/android-send-email-via-gmail-actually-via-smtp/ 

What am I doing wrong?

Thanks,
Noam.
--~--~---------~--~----~------------~-------~--~----~



Send Email Automatically

by Noam » Wed, 08 Apr 2009 02:04:18 GMT


 Mikas,
After I posted my last post I saw yours.
If the new SDK really doesn't allow it, then how did you get it to
work?

Thanks,
Noam.
--~--~---------~--~----~------------~-------~--~----~



Send Email Automatically

by Noam » Wed, 08 Apr 2009 03:20:40 GMT


 Mikas,
I just noticed your post after I posted my last one.
If that is true, then how did you get it to work?

Thanks,
Noam.
--~--~---------~--~----~------------~-------~--~----~



Send Email Automatically

by Mark Murphy » Wed, 08 Apr 2009 07:58:41 GMT


 


SMTP is for sending email. IMAP and POP3 are for receiving email.

In terms of whether the code at those links can be used for sending
email and would work on Android, that would probably be a better
question to ask of their respective authors.

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com  |  http://twitter.com/commonsguy 

Warescription: Three Android Books, Plus Updates, $35/Year

--~--~---------~--~----~------------~-------~--~----~



Send Email Automatically

by Mark Murphy » Wed, 08 Apr 2009 08:02:01 GMT


 


At least the second post is from December 2007. In Android terms, that's
back when dinosaurs roamed the Earth.

I attempted to get JavaMail working with Android 0.9 and ran into the
same problem you did. The error generally means that the JAR is not
completely compatible with Android. If you can find the source code to
JavaMail, add that source to your project, and compile it, you may be
able to identify the problem and fix it. However, you may or may not
like the JavaMail license terms.

You might also consider whether there is some other means to solve your
business issue than sending an email without user intervention on the
device.

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com  |  http://twitter.com/commonsguy 

Warescription: Three Android Books, Plus Updates, $35/Year

--~--~---------~--~----~------------~-------~--~----~



Send Email Automatically

by mikas » Wed, 08 Apr 2009 15:41:38 GMT


 The thing is, this code with "external libraries" worked fine for me
with
android-sdk_m5-rc15 and ADT-0.4.0 plugin for eclipse, but you have to
install
adt plugin manually, and then again you have to use proper javax.mail
and
activation libraries, I used those from maven java repository,
eventually I
had that code running, but it's useless within new android sdk, not to
mention
having your code run on a real device....





--~--~---------~--~----~------------~-------~--~----~



Send Email Automatically

by Noam » Wed, 08 Apr 2009 23:38:36 GMT


 So what you're trying to say is that the external libraries are
useless in the new andoid SDKs. That's fine.
I'm just wondering if there is a way to work around it? If there is a
way to do the same action, but with code that will work?

Thanks,
Noam.
--~--~---------~--~----~------------~-------~--~----~



Send Email Automatically

by Mark Murphy » Wed, 08 Apr 2009 23:52:46 GMT


 


I am not sure who "you're" is in that sentence.

External libraries may need work to behave on Android. JavaMail
definitely needs work to behave on Android.


Let the user confirm the email, as you had working before, if I
understand correctly.

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com  |  http://twitter.com/commonsguy 

Android App Developer Training:  http://commonsware.com/training.html 

--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. What is the query that need to be done when trying to get Incomming and Outgoing calls ?

Someone ??



--~--~---------~--~----~------------~-------~--~----~

2. How read /data directory ?

Hi,
sorry for my english, I'am an italian student.
I need help. I have to open, from my application, /data directory, but
using the "ls -l" command in adb shell, I read following lines :

drwxrwx--x System System      2009-05-08   11:28 data

and when I launch this code :

File data = new File("/data");
if(data.isDirectory()){
   Log.v(TAG, "directory");
}
String []child = data.list();
Log.v(TAG, String.valueOf(child.length));

I have this output :

"directory
 0
"

So my application is not able to read files located into this
directory.
Somebody can help me?

--~--~---------~--~----~------------~-------~--~----~

3. except for setting in the AndroidManifest.xml, where I can do

4. How to set two or more List in one layout?

5. where to download android 1.5 r1 source code ?

6. except for setting in the AndroidManifest.xml, where I can do

7. Menu on the center of the screen if style inherit from Theme.Dialog