I am using Gmail, Salesforce integration app, using which I can save an interested mail into Salesforce Activity History of a Contact. Now, as soon as I receive the activity history, I want to save this into a custom field, named EmailBody__c.
I have tried with the below trigger but have no luck
trigger EmailBodyTrigger on Contact(before update) {
Contact[] contacts = Trigger.new;
for(Contact c : contacts) {
try {
ActivityHistory ah = c.ActivityHistories;
if(ah != null) {
contact.EmailBody__c = 'Hello Ram, How are you';
}
} catch(System.QueryException e) {
// no trigger call
}
}
}