我正在开发一个尝试发送电子邮件数据库的应用程序。但是如果发送了axexo文件。如果没有发送附件。代码如下:
public class Enviaremail extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
MailSender mailsender = new MailSender("lalala@gmail.com", "xxxxxx");
String[] toArr = { "lalala@gmail.com"};
mailsender.set_to(toArr);
mailsender.set_from("lalala@gmail.com");
mailsender.set_subject("This is an email sent using my Mail JavaMail wrapper from an Android device.");
mailsender.setBody("Gracias a Dios.");
try {
mailsender.addAttachment("/data/data/org.segure.sms/databases/agenda.db"); ;
if (mailsender.send()) {
Toast.makeText(Enviaremail.this,
"Email enviado exitosamente.",
Toast.LENGTH_LONG).show();
} else {
Toast.makeText(Enviaremail.this, "Email no fue enviado.",
Toast.LENGTH_LONG).show();
}
} catch (Exception e) {
Log.e("MailApp", "Could not send email", e);
}
}
}
当我删除该行时:mailsender.addAttachment(“/ data / data / org.segure.sms / databases / agenda.db”)工作并发送邮件。如果我放置它不起作用。该文件存在于指定位置。提前谢谢。