This question already has an answer here:
I am making an app that allows the user to take a picture and send it automatically via email to the email he chooses. So far I was able to take a picture and store in the SD card. Now I only need functions that get the picture from the folder (/sdcard/Pictures/PhotoSender/) and send automatically to the e-mail the user has requested. How can I do this?
I have the picture in that folder. I just need some functions to generate the e-mail, put the picture (.jpg) as an attachment and send (all this on background). When the e-mail gets totally sent, a toast should pop up saying "Upload Done". Meanwhile the user should be free to take more pictures, so the uploading requests should be put on a queue. The user shouldn't login with his e-mail account to send. If needed, I can create an e-mail account for my app to be the "sender". Please help me!
Below is a complete class that supports sending emails with attachments in Android
And here is a utility function to send mail with attachment where the attachment in your case is simply the picture(s) file complete path
Here is the complete
Mail
class that is used in the above functionNote:
activiation.jar
andmail.jar
in your classpath i.e. JavaMail APIAsynchTask
or dedicatedThread
Assuming your device of emualtor has a email application, the below code can be used to sent a mail. You can use any email application installed on your emualtor or device be it yahoomail or google. If you want tp run the same in background use a service.