You need to sign in to do that
Don't have an account?
clouddev@surashri
DMLOption setting not working
Hi,
I am running below code from sandbox execute anonymous window. I am not getting any mail after execution.
Thanks,
I am running below code from sandbox execute anonymous window. I am not getting any mail after execution.
Account a = new Account(name='Acme Plumbing'); insert a; Contact c = new Contact(email='jplumber@salesforce.com', firstname='Joe',lastname='Plumber', accountid=a.id); insert c; Database.DMLOptions dlo = new Database.DMLOptions(); dlo.EmailHeader.triggerAutoResponseEmail = true; Case ca = new Case(subject='Plumbing Problems', contactid=c.id); database.insert(ca, dlo);This is exmaple from Salesforce documentation. Do I have to any setting? Could I request a help?
Thanks,
when you run this code and when the case is created, the email is sent to the email address of the contact associated to the case..
in your sample it will send the email to jplumber@salesforce.com
can you change that to your email and see if it works..
You need to specify one more property for DMLOptions.
triggerOtherEmail="Indicates whether to trigger email outside the organization (true) or not (false)"
Also specify your email while contact creation. See below working code:
Account a = new Account(name='Acme Plumbing');
insert a;
Contact c = new Contact(email='Your email id', firstname='Joe',lastname='Plumber', accountid=a.id);
insert c;
Database.DMLOptions dlo = new Database.DMLOptions();
dlo.EmailHeader.triggerAutoResponseEmail = true;
dlo.EmailHeader.triggerOtherEmail =true;
Case ca = new Case(subject='Plumbing Problems11', contactid=c.id);
database.insert(ca, dlo);
If it works, please mark it as solution.
Thanks,
Sunil Kumar
This has worked. I have one question about mail I received. Is there a possibility to set From address of my choice. In image attached I received mail from rahul.borgaonkar@xxxxxx.com. Is it possible to set it to org wide id and how ?
Thanks in advance,
Rahul
https://onegoodplumber.co.uk/west-london/