function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Karthikeyan ChandranKarthikeyan Chandran 

Save emails under Opportunity

Hi Team,

Can we save the emails to email message object under an Opportunity as like case? when we send the emails via "Send an email" option it's saving under the activity history instead of email message related list.

Thanks,
Karthikeyan
Raj VakatiRaj Vakati
Are you sending by using apex code ??

you neet to setAsActivity to true 
Karthikeyan ChandranKarthikeyan Chandran
Hi Raj,

Thanks for the response, created a custom button  "Send an email" , Opportunity lookup on the email message object. trying to send emails from an Opportunity and the email are not saving under the Opporunities email message related list.

here the custom button code,
 
{!REQUIRESCRIPT("/support/console/33.0/integration.js")} 
var contid = "{!Opportunity.Sample_App12__Contact__c}"; 
var oppid = "{!Opportunity.Id}"; 

var target_url = "https://kk1986-dev-ed.my.salesforce.com/_ui/core/email/author/EmailAuthor?p2_lkid="+contid+"&rtype=003&p3_lkid="+oppid+"&retURL=%2F"+oppid;
if (sforce.console.isInConsole()) 
{ 
//alert('In Console'); 
sforce.console.getEnclosingTabId(function(enclosingResult){ 
sforce.console.getEnclosingPrimaryTabId(function(primaryResult){ 
if(primaryResult.id == null) 
{ 
window.parent.location = target_url; 
} 
else 
{ 
sforce.console.openSubtab(primaryResult.id, target_url, true, '', null); 
} 

}); 
}); 
} 
else 
{ 
window.top.location.href = target_url; 
//window.parent.location.href = target_url; 
}

Can you please let me what i am missing here?

Thanks,
Karthikeyan