Android uses Microsoft EWS to send emails and androidews to send emails
Generally, we use javamail in android to send emails, but many times we need to connect to the Exchange Service (which is used by many internal email servers and has not activated the smtp service, at this time, we will use Microsoft's ews-java-api. The official github address is https://github.com/officedev/ews-java-api. Then add 2.0 dependencies and build in android studio according to the given method. At this time, an error is reported when compilation fails.
The content is as follows:
Caused by: java.lang.ClassNotFoundException: Didn't find class "org.apache.http.client.protocol.HttpClientContext" on path: DexPathList[[zip file "/data/app/domain.test.android.jasonyu.myfirstapp-2/base.apk"],nativeLibraryDirectories=[/data/app/domain.test.android.jasonyu.myfirstapp-2/lib/x86, /vendor/lib, /system/lib]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56) at java.lang.ClassLoader.loadClass(ClassLoader.java:511) at java.lang.ClassLoader.loadClass(ClassLoader.java:469) at microsoft.exchange.webservices.data.core.ExchangeServiceBase.initializeHttpContext(ExchangeServiceBase.java:261) at microsoft.exchange.webservices.data.core.ExchangeServiceBase.setUseDefaultCredentials(ExchangeServiceBase.java:677) at microsoft.exchange.webservices.data.core.ExchangeServiceBase.<init>(ExchangeServiceBase.java:173) at microsoft.exchange.webservices.data.core.ExchangeService.<init>(ExchangeService.java:3718) at domain.test.android.jasonyu.myfirstapp.MainActivity.onButtonGoClick(MainActivity.java:94)
The possible reason is that this api is for java web. If you want to use android, you need to use another android package: https://github.com/alipov/ews-android-api.
Compile the ews-android-api.jar through git. Then add the dependency to the project:
Compile files ('libs/ews-android-api.jar ') compile 'joda-time: joda-time: 8080'
OK.