You need to sign in to do that
Don't have an account?

EmailMessage object trigger not working. Please help
I have trigger the below simple trigger to add BCC address dynamically, but its not firing to email. It is showing in the debug log about the added email address . Please help to solve this.
Thanks,
Sai.
trigger EmailMessage_Trigger on EmailMessage (before insert) { // EmailMessage_Trigger_Helper.emailMessage(Trigger.New); for(EmailMessage emsg : Trigger.New){ if (emsg.Incoming==false && emsg.Status == '3') { emsg.BccAddress ='saiprasanth123@gmail.com'; emsg.CcAddress ='saiprasanth1234@gmail.com'; system.debug('coming sai inside:'+emsg.CcAddress+'....'+emsg.FromAddress); } system.debug('coming sai outside:'+emsg); } }
Thanks,
Sai.
When I send email from the Case record using "Send email" Action button. I have written the trigger on EmailMessage to add the cc addresses.
trigger Trigger1 on EmailMessage (before insert) {
if(Trigger.isbefore){
List<EmailMessage> listMsg = new List<EmailMessage>(trigger.New);
for(EmailMessage msg : listMsg)
{
String str = 'abcde@gmail.com,abcde@customdomain.com';
msg.CcAddress = str;
}
}
}
But some time, my email is sent to the ccddress and some time it doesn't send to the cc address.
Could anyone help me on this.
Thank You in advance.
We can not assign the array in the ccAddress.
I wrote below code:
String [] arrayOfProducts = new List<String>();
//Adding elements in Array
arrayOfProducts.add('abcde@gmail.com');
arrayOfProducts.add('gef@gmail.com');
msg.CcAddress =arrayOfProducts;
Output - Code will not compile and says "Illegal assignment from List<String> to String".
Thanks,
When I wrote like this:
List arrayOfProducts = new List();
It throws compile time exception i.e "Unexpected token 'List'."
Then I updated it to like below.
List<String> arrayOfProducts = new List<String>();
arrayOfProducts.add('abc@gmail.com');
msg.CcAddress = arrayOfProducts;
It throws compile time exception ie. "Illegal assignment from List<String> to String" so due to this, code did not saved in the developer console.
Thanks,
if(Trigger.isbefore){
List<EmailMessage> messages = new List<EmailMessage>(trigger.New);
for(EmailMessage emailMessage1 : messages)
{
List<String> arrayOfProducts = new List<String>();
arrayOfProducts.add('abc@gmail.com');
arrayOfProducts.add('abc1234@gmail.com');
emailMessage1.CcAddress = arrayOfProducts;
}
}
}