I am using Cordova 2.2.0 for iOS. I'm trying to implement the Phonegap EmailComposerWithAttachments plugin and I can't seem to get the picture attachment to work.
I call:
window.plugins.emailComposer.showEmailComposerWithCallback(function(result){console.log(result);},"Look at this photo","Take a look at this:",[],[],[],true,[testPath]);
where testPath contains the path of my PNG or JPG file. e.g. ../myImage.jpg
The Good: The email composer comes up. I see my subject, the body of the e-mail etc.
The Bad: I don't see my picture included as attachment. Instead I see a small question mark (in the emulator) and a small square (on my iPad), as if the attachment was missing.
Any ideas?
The problem was the path I was providing for the plugin.
When you get the path of a file, it looks like this:
file:///localhost/var/mobile/Applications/2BED9D97-043A-402A-B914-83F4459E8A74/myApp.app/myPicture.jpg
However, the EmailComposerWithAttachments plugin does not expect the path to start with
"file:///localhost/"
In order for the plugin to work, you need to change its path by taking out everything before var (file:///localhost/). So, the correct path would look like this:
var/mobile/Applications/2BED9D97-043A-402A-B914-83F4459E8A74/myApp.app/myPicture.jpg
Then it worked. I was able to use this plugin to send emails with picture attachments.
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