Skip to content

Instantly share code, notes, and snippets.

@illuzor
Created July 18, 2014 19:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save illuzor/1fcc08159e4cb724bbf2 to your computer and use it in GitHub Desktop.
Save illuzor/1fcc08159e4cb724bbf2 to your computer and use it in GitHub Desktop.
package com.illuzor.communicationextension.functions;
import android.content.Intent;
import android.net.Uri;
import java.util.ArrayList;
import com.adobe.fre.*;
public class SendEmailFuntion implements FREFunction {
@Override
public FREObject call(FREContext context, FREObject[] args) {
try {
String addresses = args[0].getAsString();
String subject = args[1].getAsString();
String message = args[2].getAsString();
String filesPaths = args[3].getAsString();
String[] addressesArray = addresses.split(",");
Intent emailIntent = new Intent(Intent.ACTION_SEND);
emailIntent.setType("message/rfc822");
emailIntent.putExtra(Intent.EXTRA_EMAIL, addressesArray);
emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
emailIntent.putExtra(Intent.EXTRA_TEXT, message);
if(filesPaths != ""){
String[] filesPathsArray = filesPaths.split(",");
ArrayList<Uri> uris = new ArrayList<Uri>();
for (String filePath:filesPathsArray) {
Uri uri = Uri.parse("file://" + filePath);
uris.add(uri);
}
emailIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
}
context.getActivity().startActivity(emailIntent);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment