0

I am setting up my app to use JavaMail API. I don't want to get into details, I just want to implement it in my app.

Sending Email in Android using JavaMail API without using the default/built-in app

So while importing the libraries in GMailSender.java, I am stuck on Session.

There are many options: This picture shows all the options

So from the options in this picture, which one should I select?

Didier L
  • 18,905
  • 10
  • 61
  • 103
Femn Dharamshi
  • 527
  • 1
  • 9
  • 25

2 Answers2

0

Since your GMailSender.java extends javax.mail.Authenticator, you can just pass this for session, e.g

Session.getDefaultInstance(props, this);

And the Session must be imported from javax.mail.Session

Qasim
  • 5,181
  • 4
  • 30
  • 51
  • Use [Session.getInstance](https://javaee.github.io/javamail/FAQ#commonmistakes), and make sure you're using the official [JavaMail for Android](https://javaee.github.io/javamail/Android). – Bill Shannon Aug 27 '18 at 17:04
0

I noticed javax.mail is not correctly imported, please click Sync project with Gradle Files which is in File menu. In fact the Session class uses:

import javax.mail.Session;
navylover
  • 12,383
  • 5
  • 28
  • 41