I created a method which prints the email body to the console, but I am unable to view it.

public void createCaseCommentFromEmail(){
    for (EmailMessage em : (List<EmailMessage>) Trigger.new) {
            System.debug('Email HTML Body: '+ em.HtmlBody);
            System.debug('Email Text Body: '+ em.TextBody);

I'm sending the email to a routing address (configured via Email-to-Case) so I set the debug log on the class above (EmailHandler.cls) but nothing appears in the debug logs section nor in the developer console.

How can one debug incoming/outgoing emails?

  • who is the user that is running the Email-to-Case? Sometimes, is the System. you should change for your user..
    – m Peixoto
    Apr 22, 2019 at 15:55
  • I am the one who created the routing address via Setup>Email-To-Case, so I suppose that I'm the running user. no system user
    – Json
    Apr 22, 2019 at 16:08
  • the default, is the system user....
    – m Peixoto
    Apr 22, 2019 at 16:09

1 Answer 1


You should set the Automated Case User in Support Setting for your user:

enter image description here

Also, you could get reference here -> https://help.salesforce.com/articleView?id=000004634&type=1

  • That was it, thanks!
    – Json
    Apr 22, 2019 at 16:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .