Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Phonegap EmailComposer with Attachment for iOS not working

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?

like image 532
xited Avatar asked Nov 28 '12 14:11

xited


1 Answers

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.

like image 146
xited Avatar answered Oct 22 '22 18:10

xited