这个没有用,我真的不知道为什么它不发送电子邮件错了。我已经尝试了很多代码,但我仍然没有在帐户上收到任何消息。
Thread thread = new Thread(new Runnable(){
@Override
public void run() {
try {
GMailSender sender = new GMailSender( email , "");
sender.sendMail("Hi! This is your code:", test , "sender" , "recipients");
GMailSender sender1 = new GMailSender( email1 , "");
sender1.sendMail("Hi!",
"Employee No: " + (txt_Emp.getText().toString()) + "\nDevice Name: "
+ model + "\nDevice Serial No: " + (serial.toString()) + "\nDate: "
+ (date.toString()) + "\nTime: " + (time.getText().toString()),
"sender" , "recipients");
Toast.makeText(MainActivity.this, "Email was sent successfully.",Toast.LENGTH_LONG).show();
//Toast.makeText(MainActivity.this, test,Toast.LENGTH_LONG).show();
}catch (Exception e) {
Log.e( "MainActivity" , "Email was not sent.", e);
//Log.e("Email was not sent.", e.getMessage(), e);
//Toast.makeText(MainActivity.this, "Email was not sent.", Toast.LENGTH_LONG).show();
}
}
});
我真的不知道这里有什么不对,他们说应该在asynctask或专用线程上发送电子邮件。