GithubHelp home page GithubHelp logo

Comments (10)

tbh726 avatar tbh726 commented on July 29, 2024

I am also not getting the attachment.. it show an icon of a "pdf" in the window it opens. this is what i am doing.., it does send the email without an attachment fine.

var canvas = document.getElementById('myCanvas')

var imageData = canvas.toDataURL()
console.log(imageData);

window.plugin.email.open({
                         to:      ['[email protected]'],
                         attachments: [imageData],
                         subject: 'SnapShot',
                         body:    'How are you? Nice greetings from Leipzig'
                         });

from cordova-plugin-email-composer.

avneet007 avatar avneet007 commented on July 29, 2024

Hello
Is there any one who can help me on this. ? i tried to add html in the body with
' where img is a base64 string. it showing me good on the email composer in Ipad but at receiving end nothing is there.??

from cordova-plugin-email-composer.

miguelwicht avatar miguelwicht commented on July 29, 2024

The pdf icon in the mail composer doesn't mean, that the attachment is actually working! iOS seems to add an empty attachment as long as there is a file name with an extension it knows. If you are using an image or a pdf there should be an actual preview of it if it's working.

from cordova-plugin-email-composer.

avneet007 avatar avneet007 commented on July 29, 2024

Hello

Any answer of my question i am adding simple html in the body and set the html attribute to true also. it showing me that attachment fine in the iPad but at the receiving end its not showing anything event not that html.

note:- using Google account in the iPad for sending the email.

Thanks
Avneet

from cordova-plugin-email-composer.

katzer avatar katzer commented on July 29, 2024

... I am busy at the moment :(

from cordova-plugin-email-composer.

ericcmmi avatar ericcmmi commented on July 29, 2024

I've been trying to get it to work on Android and it appears to be a problem with the storage path. I've replaced a couple of lines in EmailComposer.java with a path that works on my test phone and verified that it does work but this is not a final solution since I'm creating the folder manually and I'm not sure this will work on other phones. This is my first try at modifying an Cordova plugin so I will keep working on it and if I come up with a good solution I will post it. I'm going to look at the iOS side also.

    } else if (path.startsWith("base64:")) {
        String resName = path.substring(path.indexOf(":") + 1, path.indexOf("//"));
        String resData = path.substring(path.indexOf("//") +2);

    byte[] bytes   = Base64.decode(resData, 0);

        //String storage = this.cordova.getActivity().getCacheDir() + "/email_composer";
    String storage = "/storage/sdcard0/Android/data/de.appplant.cordova.plugin/email_composer";

        File file = new File(storage, resName);

    new File(storage).mkdir();

        try {
            FileOutputStream os = new FileOutputStream(file, true);

            os.write(bytes);
            os.flush();
            os.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

        //return Uri.parse("content://" + AttachmentProvider.AUTHORITY + "/" + resName);
    return Uri.parse("file://" + storage + "/" + resName);
    }

from cordova-plugin-email-composer.

ericcmmi avatar ericcmmi commented on July 29, 2024

Let me be a little more specific. The code

this.cordova.getActivity().getCacheDir() + "/email_composer"

returns the following for my app (PolicyHolderServices)

/data/data/com.fmins.policyholderservices/cache/email_composer

and

"content://" + AttachmentProvider.AUTHORITY

returns

content://de.appplant.cordova.plugin.emailcomposer.attachmentprovider

So there seems to be a mismatch between the path being used to create the temporary file for the attachment and the path being used to retrieve it.

from cordova-plugin-email-composer.

ericcmmi avatar ericcmmi commented on July 29, 2024

Here's what I'm going with for Android. It requires external storage but so do some of the other options in the email composer. I borrowed a little bit from the relative section and also from the following SO article. Now onto iOS.

http://stackoverflow.com/questions/3570914/android-how-do-i-attach-a-temporary-generated-image-to-an-email

    } else if (path.startsWith("base64:")) {
        String resName = path.substring(path.indexOf(":") + 1, path.indexOf("//"));
        String resData = path.substring(path.indexOf("//") +2);

        byte[] bytes   = Base64.decode(resData, 0);

        File imageDir = new File(
            Environment.getExternalStorageDirectory(),   
            "/Android/data/" + this.cordova.getActivity().getPackageName() + "/email_composer");

        if (!imageDir.exists()) {
            imageDir.mkdirs();
        }

        File file = new File(imageDir, resName);

        try {
            FileOutputStream os = new FileOutputStream(file, true);

            os.write(bytes);
            os.flush();
            os.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

        return Uri.fromFile(file);
    }

from cordova-plugin-email-composer.

avneet007 avatar avneet007 commented on July 29, 2024

Hello
any update regarding sending the html data in body ??

from cordova-plugin-email-composer.

katzer avatar katzer commented on July 29, 2024

Hello,

both relative:// and base64:// had an error, which have been fixed now (missing permission and wrong dir path).

from cordova-plugin-email-composer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.