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
EdCodeEdCode 

Restrict Agents from sending messages from their own email address

Can we restrict an Support Agent from sending Email messages from the Salesforce FROM with his/her Nominal Address?

Support Agents are supposed to send Emails only FROM the predefined Organization-Wide Email Addresses or Email-to-Case addresses (but NOT from their nominal addresses).

In other words:
We want to avoid Agents from sending messages from addresses like john.smith@cognizant.com;

We want all Agents to send messages from predefined addresses such as contact@corporateDomain.com;

I do not think that is possible with point-and-click configuration in Salesforce (I am not finding anything usefule in the documentation).

I can think of a "Before Apex Trigger" to display a message but... it would not look good (the john.smith@cognizant.com address would still appear on the FROM drop-down list of addresses, even if we can stop the Agent from sending it with that "Before Apex Trigger).

Any idea of how I could restrict an Agent user from using his/her own address to send an outbound email mssge from objects like Leads, Contacts, Cases, etc. ?
Best Answer chosen by EdCode
mukesh guptamukesh gupta
Hi,

Please follow below code:-
 
trigger BlackListEmailAddress1 on EmailMessage (before insert) {
    for(EmailMessage message: Trigger.New)
    {
        if((message.ToAddress.contains('gmail')) && message.Incoming == false )
        {
            message.addError('Email Alert: You have selected a receipient email from one of the blacklisted doamins please use another email address and try again');
        }
        if((message.ToAddress.contains('yahoo')) && message.Incoming == false )
        {
            message.addError('Email Alert: You have selected a receipient email from one of the blacklisted doamins please use another email address and try again');
        }
    }
}
if you need any assistanse, Please let me know!!

Kindly mark my solution as the best answer if it helps you.

Thanks
Mukesh