Skip to content

se6wagner/Email2Apex

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 

Repository files navigation

E2A - Email2Apex

Toolkit for executing Apex Code from Apex Email Services.

FEATURES

  • batch job chaining / async execution
  • support for parameters incl. complex data types through JSON serialization
  • trigger Apex Code from any application with no need for Webservice Integration by just sending an email to SFDC
  • simple API (check usage)

SETUP

    1. Register an Apex Email Service using the E2A_InboundEmailHandler class
    1. In Custom Settings create E2A_CONFIG__c Org Default
    1. Implement E2A.Executable or E2A.ExecuteableWithParams contracts in the classes you want to run (Check out E2A_SampleBatch1 and E2A_SampleBatch2 for more details)

USAGE

CAUTION:: Be careful when using custom data types as parameter objects, deserializing classes using (DATA_TYPE)JSON.deserialize((String)paramsObj, DATA_TYPE.class); causes an 'System.JSONException: Don't know the type of the Apex object to deserialize' error in production like EMEA (as of Winter '12)

//
// sendE2AMessage
//
// Sends an E2A ready message with Attachments
// - class_name.e2b (Contains className)
// - param_class.json.e2a (Contains JSON serialized paramsObj if doSerialze is true)
// to the E2A Apex Email Service you have setted up
//
// @throws OutboundEmailException
//
E2A.sendE2AMessage(
	  String className // Name of the Apex class to execute
	, Object paramsObj // Object holding parameters used by the executed class
	, Boolean doSerialze // True serializes the paramsObj to JSON
	, Boolean checkResult // True to throw an Exception if result is negativ
	, String emailBody // Plain Text Body to set
);

// SAMPLE
// Execute a Database.Batchable class called 'IBaseImport_Batch'
E2A.sendE2Message('IBaseImport_Batch',false,'Completed IBaseImport_Setup, start IBaseImport_Batch');

E2A accepts class names contained in the Email Subject as well, just sent an email to the Email Inbound Service with the plain class name in the subject

About

Execute Apex from Inbound Email

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published