Salesforce Apex sending email

For example, how to log issue in SFDC by sending email?

Solution

How to log issue in SFDC by sending email?

Sometimes, we may want to perform some data patch/execute some batch job in salesforce Developer Console instead of Data loader. we may write some apex code in Developer Console ‘Anonymous Window’. To log the record, we may use ‘System.debug(‘somethings’);’ to print the information,but we can also use following method to save the log .

Debug–>Open Execute Anonymous Window ( Ctrl+E)

alt tag

and then

alt tag

Code

Sending Email Method

Insert Record Method

If we want to insert the log into one object, we can insert our log into Attachment also:

Please note that we need to create object name ‘Log__c’ to save the record.

Any code samples provided here are purely for experimental purposes and comes with no warranty or support. The primary purpose of this article is just to share the knowledge and my own experience. Nothing more, nothing less. Use this code and approach at your own risk.Please feel free to contact me (yamshingkwan@gmail.com) if you have any inquiry or the code have any problem. Thank you.