java - Sending Android mail with Javax mail without attachment -


i'm trying sent email javax mail resources find online attachment code throws error:

public boolean send() throws exception {         properties props = _setproperties();          if(!_user.equals("") && !_pass.equals("") && _to.length > 0 && !_from.equals("") && !_subject.equals("") && !_body.equals("")) {             session session = session.getinstance(props, this);              mimemessage msg = new mimemessage(session);              msg.setfrom(new internetaddress(_from));              internetaddress[] addressto = new internetaddress[_to.length];             (int = 0; < _to.length; i++) {                 addressto[i] = new internetaddress(_to[i]);             }             msg.setrecipients(mimemessage.recipienttype.to, addressto);              msg.setsubject(_subject);             msg.setsentdate(new date());              // setup message body             bodypart messagebodypart = new mimebodypart();             messagebodypart.settext(_body);             _multipart.addbodypart(messagebodypart);              // put parts in message             msg.setcontent(_multipart);             final  mimemessage msg2 = msg;             // send email             new thread(new runnable() {                 @override                 public void run() {                     try {                         transport.send(msg2);                     } catch (messagingexception e) {                         e.printstacktrace();                     }                 }             }).start();              return true;         } else {             return false;         }     } 

it ends throwing:

w/system.err: javax.mail.messagingexception: ioexception while sending message; w/system.err:   nested exception is: w/system.err:   java.io.filenotfoundexception: /sdcard/filelocation (no such file or directory) w/system.err:     @ com.sun.mail.smtp.smtptransport.sendmessage(smtptransport.java:676) w/system.err:     @ javax.mail.transport.send0(transport.java:189) w/system.err:     @ javax.mail.transport.send(transport.java:118) w/system.err:     @ com.example..logintest.mail$1$override.run(mail.java:143) w/system.err:     @ com.example..logintest.mail$1$override.access$dispatch(mail.java) w/system.err:     @ com.example..logintest.mail$1.run(mail.java:0) w/system.err:     @ java.lang.thread.run(thread.java:761) w/system.err: caused by: java.io.filenotfoundexception: /sdcard/filelocation (no such file or directory) 

i couldn't find online , i'm not trying send file. _body simple string. ideas? don't understand how set fields wont try send attachment.


Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -