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
mact1079mact1079 

How to send an automatic email to contact 2 days after an opportunity is created?

I'm a little stuck on how to send an email to a contact after an opportunity is created.

 

I'm able to send an email immediately with the code below but how can I get it to send a couple days later? I've attempted to set up a workflow for opportunity records but when I attempt to setup an Email Alert it does allow me to select the contact email as the recipient. Not sure how to work around this or if I'm doing something wrong.

 

Any help would be much appreciated.

 

   //Now send welcome email
  $emailID = $sObject->Email; // User email from Noo DB
  $singleEmail1 = new SingleEmailMessage();
  $singleEmail1->setToAddresses(array($emailID));
  $singleEmail1->setreplyTo("test@test.com");
  $singleEmail1->setSenderDisplayName("Test sender");
  $singleEmail1->setSaveAsActivity(true);
  $singleEmail1->setTargetObjectId($SalesForceContactID);
  $singleEmail1->setTemplateId('');
  $singleEmail1->setEmailPriority(EMAIL_PRIORITY_NORMAL);

ShwetaSShwetaS

Hi,

 

You can use workflow and add time trigger.  With the help of Time trigger you can perform the workflow action on a specific time.

 

Shweta
Salesforce Developer Support

If my answer solved your question, please mark it solved so I can help as many community members as possible!