• kevin chong
  • NEWBIE
  • 0 Points
  • Member since 2008

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies
Hi mates,
I got problems when sending emails, the code like following:
 
  Messaging.SingleEmailMessage mail=new Messaging.SingleEmailMessage();
  mail.setTemplateId(emailTemplateId);
  mail.setTargetObjectId(myContactId);
  mail.setWhatId(customObjectId);
  Messaging.sendEmail(new Messaging.SingleEmailMessage[]{mail});
The problem is on customObjectId, i know the whatId can be set to some standard object and the custom objects. But there are some custom objects cannot set to whatId. For example, i got a RFQ object, its fields are almost the same with another Schedule object. When setting the RFQ id, it works fine. When setting the Schedule id, i got a exception like following:
 
System.EmailException: SendEmail failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, Opportunity/Account ID: id value of incorrect type: a0070000009w4JMAAY: [WhatId]
 
So, is there a restriction of which custom object can be bound to the whatId field.
 
Thanks very much
Kevin