This is a migrated thread and some comments may be shown as answers.

How to send email with attachment

1 Answer 157 Views
General Discussion
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Alex
Top achievements
Rank 1
Alex asked on 21 Jul 2014, 01:42 AM
Hi,

I would like to know how to trigger and open the native email app with attachment.

1. I downloaded the file(s) in mobile local storage
2. Press any button to open native email app
3. The email draft which enclose that file(s)

Thanks.

1 Answer, 1 is accepted

Sort by
0
Martin Yankov
Telerik team
answered on 23 Jul 2014, 12:53 PM
Hi Alex,

Thank you for contacting Telerik support.

You should try the SocialSharing Plugin from the Verified Plugins Marketplace. Along with sharing to social media, It supports starting a mail app with all the possible mail settings, attachments etc. Once you have installed the plugin in your project and the deviceready event has fired, you can use the following piece of code to start the default email app with the corresponding mail content:
// check for a configured email client
window.plugins.socialsharing.canShareViaEmail([success], [error]);
  
// share something
window.plugins.socialsharing.shareViaEmail(
  'Message',
  'Subject',
  ['to@person1.com', 'to@person2.com'], // TO: must be null or an array
  ['cc@person1.com'], // CC: must be null or an array
  null, // BCC: must be null or an array
  ['https://www.google.nl/images/srpr/logo4w.png'], // FILES: null, a string, or an array
  onSuccess, // called when email was sent or canceled, no way to differentiate
  onError // called when something unexpected happened
);

As a file attachment you can also use the device file path string or the base64 string path of the file.

On the SocialSharing Plugin page, you can click "Try Plugin in AppBuilder" and it will load the plugin's sample app where u can test the functionality.

I hope this solution works for you. Let me know in case you experience any problems or have any further questions.

Regards,
Martin Yankov
Telerik
 

Visit the Telerik Verified Plugins Marketplace and get the custom Cordova plugin you need, already tweaked to work seamlessly with AppBuilder.

 
Tags
General Discussion
Asked by
Alex
Top achievements
Rank 1
Answers by
Martin Yankov
Telerik team
Share this question
or