When our users leverage the email-to-saleforce feature that allows them to bcc emails to salesforce, those emails are added as Tasks of type 'Email' in the Activity History related list for relevant Contacts, Accounts, Leads, and Opportunities.

I have a trigger that processes Tasks of type 'Email' based on the whatIds associated with the Task. Unfortunately, the whatIds for tasks coming from email-to-salesforce distro have a null whatId and whoId even though they show on the Activity History related list.

Has anyone run into this before? Can anyone recommend a fix?


I'm working with Accounts. Here is a System.debug dump of the task object that is created and associated to the Account when email-to-salesforce is used. Note that the whoId and whatId are both null even though the Task shows up in the related list.

18:40:22:465 USER_DEBUG [24]|DEBUG|{null=Task:{LastModifiedDate=2015-05-29 22:40:22, CallDisposition=null, ActivityDate=2015-05-29 00:00:00, IsClosed=true, WhoCount=0, RecurrenceTimeZoneSidKey=null, RecurrenceInstance=null, RecurrenceType=null, IsHighPriority=false, CallType=null, Activity_Type__c=null, Tasking_Date__c=null, IsArchived=false, CallObject=null, RecurrenceEndDateOnly=null, RecurrenceMonthOfYear=null, AccountId=null, CreatedById=005i0000003Tu6yAAC, IsDeleted=false, Id=00T19000003AJPAEA4, CS_Contact_Date__c=null, RecurrenceStartDateOnly=null, RecurrenceDayOfMonth=null, Type=Email, OwnerId=005i0000003Tu5yABC, RecurrenceRegeneratedType=null, IsRecurrence=false, IsReminderSet=false, WhoId=null, SystemModstamp=2015-05-29 22:40:22, WhatCount=0, Description=Additional To: xxx@email.com


I am also faced that same issue when a task is created Using Email To Salesforce.

So to fix the issue I moved my trigger code that is doing some operation on the basis of AccountId into a future method.

So now, whenever a task is created and WhatId, WhoId, or Account Id is blank, I am calling a future method from trigger .

See here to get more information regarding future methods :https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_invoking_future_methods.htm

| improve this answer | |

Which object's Activity History related list are you referring to? It sounds like Opportunity is not being set on these tasks.

AccountId is it's own Activity field but it's not exposed on the page layout. AccountId is inherited from the parent of the WhatId when it is a Case or Opportunity or the WhoId when it is a Contact.

Perhaps look at WhoId or AccountId instead?

| improve this answer | |
  • post edited with additional details. – Thomas Graves Jun 1 '15 at 10:55
  • ok - so what related list do these tasks show up on? – RyanP Jun 1 '15 at 18:21
  • They show up on the Accounts -> Activity History and the Contacts -> Activity History – Thomas Graves Jun 3 '15 at 13:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.