I have written a task (actually copied from Internet), it sends email to given email. But when I run it, I get java.lang.ClassNotFoundException: javax.mail.internet.MimeMessage
exception. I have included compile group: 'javax.mail', name: 'javax.mail-api', version: '1.5.1'
in dependencies but still getting this. Here is the task
apply plugin: 'com.android.application'
class MailSender extends DefaultTask {
@TaskAction
def sendMail(){
def mailParams = [
mailhost: "smtp.gmail.com",
mailport:"465",
subject: "Email Recieved",
messagemimetype: "text/plain",
user: "allaudinqazi@gmail.com",
password:"", //
enableStartTLS:"true",
ssl:"true"
]
ant.mail (mailParams) {
from (address:'allaudinqazi@gmail.com')
to (address:'allaudinqazi@gmail.com')
}
}
}
android {
compileSdkVersion 23
buildToolsVersion '23.0.1'
defaultConfig {
applicationId "uk.org.sportscotland.app"
minSdkVersion 16
targetSdkVersion 21
versionCode 3
versionName "1.1.1"
}
dexOptions {
javaMaxHeapSize "2g"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.2.0'
compile files('libs/org.apache.http.legacy.jar')
compile fileTree(dir: 'libs', include: 'Parse-1.7.0.jar')
compile 'com.koushikdutta.ion:ion:2.+'
compile group: 'javax.mail', name: 'javax.mail-api', version: '1.5.1'
}
ext {
fileName = "SSV01"
}
task copyToDropbox(type: Copy){
from "build/outputs/apk/app-debug.apk"
into "F:/folder/Dropbox/Builds/SS"
rename {
fileName + ".apk"
}
}
task mail(type: MailSender){}