Sandip Armal Patil
Sandip Armal Patil

Reputation: 5895

How to receive the email with attachment?

How to use javaMail API in android for receiving mail with attachment.
Pls give me some code or steps which is use in Android.

Upvotes: 1

Views: 254

Answers (1)

OnkarDhane
OnkarDhane

Reputation: 1460

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);

Upvotes: 1

Related Questions