Accessing Email logs using REST or SOQL

For Email Logs, we follow below steps generally:
Go to Setup–> Logs –> Email Log Files –> Request an Email Logs –> Download(once it is ready).

Is there any way to access this information programatically using REST API or using SOQL.
In which object, these information is stored?

Answer

TL;DR – Doesn’t seem to be available.

So the object in question here is LogSearchResult. I found this SObjectType by looking at the link to one of these logs. It looked like:

https://instance.salesforce.com/servlet/servlet.FileDownload?file=0BR000000000000

So then I plugged that in to my time tested strategy:

system.debug(Id.valueOf('0BR000000000000').getSObjectType()); // yields LogSearchResult

However, when I tried to debug the fields and child relationships of this object, I got bupkus.

SObjectType logType = Id.valueOf('0BR000000000000').getSObjectType();

for (SObjectField field : logType.getDescribe().fields.getMap().values())
    system.debug(field); // nada

for (ChildRelationship relation : logType.getDescribe().getChildRelationships())
    system.debug(relation); // nada

I also tried querying for it in the Developer Console with and without the Tooling API, and got the error:

sObject type ‘LogSearchResult’ is not supported.

LogSearchResult Query Error

Also, this object seems to be missing from the listed Metadata Types.

Attribution
Source : Link , Question Author : Hari , Answer Author : Adrian Larson

Leave a Comment