• jpuckety
  • 0 Points
  • Member since 2013

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
  • 2
Hi there --

I'm setting up a trigger to automatically generate an autoresponse e-mail when a case is opened through our website (which requires a secure login).

I have everything working as I want it, except that I can't seem to access the Case.ThreadID that we use for our e-mail templates from within the trigger. I've searched documentation, but can't find out how to refer to it in SOQL land. We need it for when customers reply to the auto-response - otherwise, a new case is created, which we want to avoid.


Here's the code:

trigger SendAutoResponse on Case (after insert) {

// Iterate over each sObject
for (Case a : Trigger.new) { }

String CaseId = [Select Id, ParentId, SuppliedName, CaseNumber, UID__c, AID__c, Description FROM Case WHERE Id IN :Trigger.new].Id;
String ContactID = [Select Id, ContactID FROM Case WHERE Id IN :Trigger.new].ContactID;

// Create a new single email message object
// that will send out a single email to the addresses in the To, CC & BCC list.
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();

// Specify the address used when the recipients reply to the email.
// Specify the name used as the display name.
mail.setSenderDisplayName('Our Support');

// Who do I send the e-mail to?

// Specify the text content of the email.

// Send the email you have created.
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });

// Saves as an acivity.


Many thanks -