• mact1079
  • NEWBIE
  • 0 Points
  • Member since 2010

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies

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);