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

Replicate "Send notification email to contact" checkbox on a Visualforce Page
Hi All,
I'm trying to replicate the standard "Send notification email to contact" checkbox, visible in the bottom of the Case edit page layout, in a custom Visualforce page.
If the user puts this flag, an email will be sent to the contact related to the case and this action will be historized as completed task, both in creation and editing.
I'm trying setting the "triggerAutoResponseEmail" parameter of the DMLOption class and passing this option in the update command.
This is my code:
This code doesn't work because the parameter "triggerAutoResponseEmail" sends an email only after the case creation and not after editing.
How can I replicate the standard "Send notification email to contact" checkbox functionality via Apex?
Thank you in advance.
Edoardo
I'm trying to replicate the standard "Send notification email to contact" checkbox, visible in the bottom of the Case edit page layout, in a custom Visualforce page.
If the user puts this flag, an email will be sent to the contact related to the case and this action will be historized as completed task, both in creation and editing.
I'm trying setting the "triggerAutoResponseEmail" parameter of the DMLOption class and passing this option in the update command.
This is my code:
public with sharing class MyController { private Case c; public Boolean sendEmail {get; set;} public MyController(ApexPages.StandardController ctrl) { c = (Case) ctrl.getRecord(); sendEmail = false; } public PageReference save() { try { Database.DMLOptions dmo = new Database.DMLOptions(); if(sendEmail) dmo.EmailHeader.triggerAutoResponseEmail = true; Database.update(c, dmo); } catch (Exception e) {} } }
This code doesn't work because the parameter "triggerAutoResponseEmail" sends an email only after the case creation and not after editing.
How can I replicate the standard "Send notification email to contact" checkbox functionality via Apex?
Thank you in advance.
Edoardo
the problem is not how I invoke the code, but that the code doesn't work as expected.
Edoardo