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
Rob LilleyRob Lilley 

Email button that sends an email to a specific email address

Dear Developers,

I have a custom email button on a custom object that works fine, however I have a couple of questions if anybody could help...?

1 - After clicking on button, user has to then search fro contact in the To field and then select email address - is it possible to add something to the button code (below) that will populate the To field automatically with the email address of the Primary Contact?

2 - Also we may have the need to send each email to a fixed internal email address (for checking) before forwarding on. is it possible to add something to the button code (below) that will allow the email to be sent to a fixed email address?

Many thanks, Rob 


{!REQUIRESCRIPT("/soap/ajax/22.0/connection.js")} 

var query = "Select ContactId, OpportunityId, IsPrimary From OpportunityContactRole Where OpportunityId='{!Opportunity.Id}' AND IsPrimary=true"; 

var result = sforce.connection.query(query); 
var records = result.getArray("records"); 
var location ="/_ui/core/email/author/EmailAuthor?new_template=1&template_id=00X0Y000000IXbm&p3_lkid={!Match__c.Id}&retURL=/{!Match__c.Id}&rtype=003";; 
var contId =''; 
if (records != '') { 
contId = records[0].ContactId; 

if( contId != '' ){ 
location = location+"&p2_lkid="+contId; 

window.location=location ;
SalmanSalman
Hii  Rob Lilley ,

can you please check this app for avoiding daily email limit in Salesforce
 
MassMailer lets you send unlimited emails from within Salesforce, no matter which edition you use. Built on the Salesforce platform, it has all the mass email features you’ll ever need.Build, send, and schedule professional-looking emails with a simple to use email Wizard within Salesforce – no HTML experience required.

You can try this app by installing from appexchange- MassMailer 

For Developer's Guide please click here-Developer's Guide

You can learn more details about the product on this website -Link