Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Body of email is ignored in Outlook - Solution code is potentially added in my post! #283

Closed
kraakk001 opened this issue Dec 6, 2017 · 5 comments

Comments

@kraakk001
Copy link

Dear reader,

I have stumbled upon an issue where the Outlook mail app, ignores the body that is set when tested on Android 7.0

I looked into the code for Android and I noticed that the type is only set when there are attachments to be send. According to this topic on stackoverflow the type is required when a body is set.
https://stackoverflow.com/questions/16500545/email-body-doesnt-show-when-using-an-intent

So there are 2 solutions I came up with:

  1. Always call Intent.setType("message/rfc822");
  2. Alter the method like this so the user can decide to add it's required type:
Intent getDraftWithProperties (JSONObject params, Context ctx) throws JSONException {

    Intent mail = getEmailIntent();
    String app  = params.optString("app", MAILTO_SCHEME);

    // Added code here to support type:
    if (params.has("type")){
		// Apply the type:
		mail.setType(params.getString("type");  
    }
    if (params.has("subject"))
        setSubject(params.getString("subject"), mail);
    if (params.has("body"))
        setBody(params.getString("body"), params.optBoolean("isHtml"), mail);
    if (params.has("to"))
        setRecipients(params.getJSONArray("to"), mail);
    if (params.has("cc"))
        setCcRecipients(params.getJSONArray("cc"), mail);
    if (params.has("bcc"))
        setBccRecipients(params.getJSONArray("bcc"), mail);
    if (params.has("attachments"))
        setAttachments(params.getJSONArray("attachments"), mail, ctx);

    if (!app.equals(MAILTO_SCHEME) && isAppInstalled(app, ctx)) {
        mail.setPackage(app);
    }

    return mail;
}

Please let me know if you can apply this change so I can maybe use it to resolve my issue with Outlook.
Since the body is filled in properly when using Gmail. But I can't know for certain the the users of my app will always use Gmail.

Thanks in advance!

Koen

@JScones
Copy link

JScones commented Jan 12, 2018

Sorry to revive this, but I still don't seem to be able to get the body to work in Outlook on Android.

I'm testing on a device on Android 8.1.0, and other apps on the device are able to open an email in Outlook with the body filled.

If I choose gmail as the app to handle the email the body fills fine. Yet, if I choose outlook the email opens with all the fields filled as they should (To, CC, BCC, Attachments etc.) except the body is empty.

I have tried with and without attachments, setting ( and not setting ) type: 'message/rfc822' and nothing seems to work.

Using the example opens with no body

cordova.plugins.email.open({
    to:      'max@mustermann.de',
    cc:      'erika@mustermann.de',
    bcc:     ['john@doe.com', 'jane@doe.com'],
    subject: 'Greetings',
    body:    'How are you? Nice greetings from Leipzig'
});

and if I set type

cordova.plugins.email.open({
    to:      'max@mustermann.de',
    cc:      'erika@mustermann.de',
    bcc:     ['john@doe.com', 'jane@doe.com'],
    subject: 'Greetings',
    body:    'How are you? Nice greetings from Leipzig',
    type:    'message/rfc822'
});

it causes Android to say 'No apps to perform this action'.
Am I setting it correctly?

Would be awesome if someone else could confirm this is not working, or show me some example code that works?

@katzer
Copy link
Owner

katzer commented Jan 12, 2018

Does setting isHtml:false change anything?

@JScones
Copy link

JScones commented Jan 14, 2018

Yes! it works. I swear I tried that but thank you.

@kraakk001
Copy link
Author

Glad to hear this enhancement has been added and that JSCones managed to get it to work for outlook to.
Big thumbs up!

@AncubateChand
Copy link

cordova.plugins.email.open({
to: 'max@mustermann.de',
cc: 'erika@mustermann.de',
bcc: ['john@doe.com', 'jane@doe.com'],
subject: 'Greetings',
body: 'How are you? Nice greetings from Leipzig',
isHtml: false,
type:'message/rfc822'
});

this is my code but it still give error of 'No apps to perform this action'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants