我的应用程序中有一个邮件功能,直到今天才正常工作,我在一个月左右没有碰过。
以下是我在我的应用中添加的邮件程序的链接:http://www.jondev.net/articles/Sending_Emails_without_User_Intervention_%28no_Intents%29_in_Android
我的问题在于条件,m.send()由于某种原因没有被调用,但是else语句工作正常。我完全没有任何错误,并没有抓到任何东西。有人可以告诉我我的计划发生了什么事吗?
public void Mailing(String inputName, String inputPassword)
{
Mail m = new Mail(inputName, inputPassword);
String[] toArr = {"fake@gmail.com"};
m.setTo(toArr);
m.setFrom(inputName);
m.setSubject("Daily Time Card");
m.setBody("");
try
{
m.addAttachment(Environment.getExternalStorageDirectory().toString() + "/test");
if(m.send())
{
Toast.makeText(TaskReminderActivity.this, "Email was sent successfully.", Toast.LENGTH_LONG).show();
}
else
{
Toast.makeText(TaskReminderActivity.this, "Email was not sent successfully.", Toast.LENGTH_LONG).show();
}
} catch(Exception e) {
Toast.makeText(TaskReminderActivity.this, "There was a problem sending the email.", Toast.LENGTH_LONG).show();
Toast.makeText(TaskReminderActivity.this, "Value of User Name is " + inputName, Toast.LENGTH_LONG).show();
Toast.makeText(TaskReminderActivity.this, "Value of Password is " + inputPassword, Toast.LENGTH_LONG).show();
Toast.makeText(TaskReminderActivity.this, "Value of Attachment is " + Environment.getExternalStorageDirectory().toString() + "/test.txt", Toast.LENGTH_LONG).show();
Log.e("MailApp", "Could not send email", e);
}
}