How to use javaMail API in android for receiving mail with attachment.
Pls give me some code or steps which is use in Android.
Asked
Active
Viewed 249 times
1

djot
- 2,952
- 4
- 19
- 28

Sandip Armal Patil
- 6,241
- 21
- 93
- 160
-
1please do some google and R&D before posting your Question here. – Feb 13 '12 at 12:21
1 Answers
1
Please Do some R&D before posting.what you tried before posting this Question?
check this how to getAuth token and send email in background?
For attachment you can use this. i have given some sample to attach image from your gallery.
MimeBodyPart attachmentPart = new MimeBodyPart();
FileDataSource fileDataSource = new FileDataSource(path_img) {
@Override
public String getContentType() {
return "image/jpg";
}
};
attachmentPart.setDataHandler(new DataHandler(fileDataSource));
attachmentPart.setFileName("image.jpg");
multipart.addBodyPart(messageBodyPart);
multipart.addBodyPart(attachmentPart);
message.setContent(multipart);

Community
- 1
- 1

OnkarDhane
- 1,450
- 2
- 14
- 24
-
Dear is this really an answer? Instead it should be a comment as per the SO rule. – Paresh Mayani Feb 13 '12 at 12:14
-
@PareshMayani check updated ans. and as i have given ans. to related Question then is it necessary to post whole ans. again here? – OnkarDhane Feb 13 '12 at 12:19
-
if answer is already exists, then you just need to provide an answer link on question as a comment, not as a Redundant answer. – Paresh Mayani Feb 13 '12 at 12:21