You need to sign in to do that
Don't have an account?
TBouscal
SingleEmailMessage.setSaveAsActivity doesn't save as activity
Hello world!
What am I overlooking?
When I run my test I can see the debug line stating that the send was successful but my assertion fails because the expected task record doesn't exist.
What am I overlooking?
When I run my test I can see the debug line stating that the send was successful but my assertion fails because the expected task record doesn't exist.
For (Contact c:myRecipients){ Id EvId = EventMap.get(c.id); String theMsg = ('Please click the link below, or copy and paste into your browser to complete a brief survey '); theMsg = theMsg + ('related to your recent interaction with an Acme service representative. \n \n '); theMsg = theMsg + ('http://www.acmewidgets.com/survey?iv=xfjtzd9uazro&q1=' + EvId + '&q2=' + c.id); System.debug(theMsg); Messaging.SingleEmailMessage myEmail = new Messaging.SingleEmailMessage(); myEmail.setSenderDisplayName(owa.DisplayName); myEmail.setReplyTo(owa.Address); System.debug('c.id = ' + c.id); myEmail.setTargetObjectId(c.id); myEmail.setUseSignature(false); myEmail.setSubject('Please complete this survey from Acme'); myEmail.setPlainTextBody(theMsg); myEmail.setSaveAsActivity(true); Messaging.SingleEmailMessage[] theMessages = new List<Messaging.SingleEmailMessage>{myEmail}; Messaging.SendEmailResult[] results = Messaging.sendEmail(theMessages); if (results[0].success){ System.debug('The email was sent'); } else { System.debug('The email failed to send: ' + results[0].errors[0].message); } }
Before Update.
I only posted that snippet because the only item failing is the setSaveAsActivity = true. The email says it sends but the task it should have created didn't get created.
Here's the trigger:
The class:
and the test class:
(testNewEventNoTask is the only method that fails)
The desired outcome is that a message is sent when an event is completed as long as the customer isn't Acme and they haven't received a survey in the past 6 months.
List<Task> TskList1 = [SELECT id, subject FROM task WHERE whoid=:c.Id];
Let us know if this will help you