I have an application where I send EMails using an intent as shown below:
//TODO attach and send here
try {
Log.i(getClass().getSimpleName(), "send task - start");
String address = "emailHere@yahoo.com";
String subject = "Order of " + customer + " for " + date;
String emailtext = "Please check the attached file. Attached file contains order of " + customer;
final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND_MULTIPLE);
emailIntent.setType("plain/text");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { address });
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, emailtext);
ArrayList<Uri> uris = new ArrayList<Uri>();
Uri uriList = Uri.fromFile(orderListFile);
uris.add(uriList);
emailIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
this.startActivity(Intent.createChooser(emailIntent, "Send mail..."));
}
catch (Throwable t) {
Toast.makeText(this, "Request failed: " + t.toString(),
Toast.LENGTH_LONG).show();
}
Now, the user chooses which application he or she wants to use in order to send that EMail. However, once the selected Email application takes over, I know there's no way to figure out if the email was sent properly or not. It has been discussed in several questions here that using startActivityForIntent()
does not help since RESULT_OK
is never sent by the EMail or GMail Ap so I wouldn't know if the user sent, discarded, or saved the email as a draft.
However, one possible work around is to check the Sent Items of that email account and check from there if the user sent an email or not. Now, is there a way to know the sent items of an email account in Android? I've been doing a google search for the past hour and I can't seem to get anything.