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 = "[email protected]";
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.
The recipient never got the email you sent If the email isn't there, you might have deleted it before you sent it. Ask the recipient to check their Junk or Spam. If it's there, have them add you to their contacts so the next email goes through. Wait a few hours to see if you get a delivery error message.
You cannot check the content of the Email ContentProvider, because this requires a permission that only system apps can request. This is defined in AndroidManifest for Email:
<permission
android:name="com.android.email.permission.ACCESS_PROVIDER"
android:protectionLevel="signature"
android:label="@string/permission_access_provider_label"
android:description="@string/permission_access_provider_desc"/>
…
<application>
…
<!-- This provider MUST be protected by strict permissions, as granting access to
it exposes user passwords and other confidential information. -->
<provider
android:name=".provider.EmailProvider"
android:authorities="com.android.email.provider;com.android.email.notifier"
android:exported="true"
android:permission="com.android.email.permission.ACCESS_PROVIDER"
android:label="@string/app_name"
/>
…
</application>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With