• skp
  • NEWBIE
  • 0 Points
  • Member since 2007

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 2
    Replies
Hi,
 
MassEmailMessage does not evaluate CustomObject values, in the defined Email Template - it seems this at present is a limitation.
 
As a woraround I am planning to use SingleEmailMessage where I would get the "Subject" from the relevant EmailTemplate object.
 
Say my "Subject" in the database is "Email from {!CustomObject__c.Info__c}".
 
Question: How do I assign this value to "singleRequest.subject" (where singleRequest = new sforce.SingleEmailMessage())
 
If I assign the value straight from the database, my subject line would still contain  "Email from {!CustomObject__c.Info__c}" and NOT  "Email from value from CustomObjectField" ===> where I am assuming that {!CustomObject__c.Info__c} gets evaluated to "value from CustomObjectField""
 
I think it is something very simple, but ...
 
Hope I am clear.
 
Thanks in advance!
  • May 31, 2007
  • Like
  • 0

stringQuery = "select Id from emailtemplate where name = 'TestNotification'";

result = sforce.connection.query(stringQuery);

var templateId = result.getArray("records")[0].Id;

alert("Template ID: "+templateId);

var massRequest = new sforce.MassEmailMessage();

massRequest.targetObjectIds = toIDsArray;

massRequest.templateId = templateId;

var sendMailRes = sforce.connection.sendEmail([massRequest]);

for (i=0; i< toIDsArray.length; i++)

{

alert("Email sent to user id: "+toIDsArray[i]);

}

I can see (through the alerts that the TemplateId and User IDs are correct)

Thanks in advance

  • May 31, 2007
  • Like
  • 0

stringQuery = "select Id from emailtemplate where name = 'TestNotification'";

result = sforce.connection.query(stringQuery);

var templateId = result.getArray("records")[0].Id;

alert("Template ID: "+templateId);

var massRequest = new sforce.MassEmailMessage();

massRequest.targetObjectIds = toIDsArray;

massRequest.templateId = templateId;

var sendMailRes = sforce.connection.sendEmail([massRequest]);

for (i=0; i< toIDsArray.length; i++)

{

alert("Email sent to user id: "+toIDsArray[i]);

}

I can see (through the alerts that the TemplateId and User IDs are correct)

Thanks in advance

  • May 31, 2007
  • Like
  • 0
Hi,
  i am not able to set any Case fields with the sending mail while using MassEmailMessage(). But this is sucessfully working on SingleEmailMessage().

The following fields i want to populate in an email using any template:

1.   {!EmailMessage.Subject}
2.  {!Case.Solution_Description}
3.  {!Case.CaseNumber}.
4.  {!EmailMessage.FromName}
5   {!EmailMessage.FromAddress}
6   {!EmailMessage.ToAddress}
7   Re: {!EmailMessage.Subject}
8   {!EmailMessage.TextBody}



The code is given below:

function sendMail(templateId)
{
    var massRequest = new sforce.MassEmailMessage();
   
    contactIDArray[0]= contactID;
    massRequest.targetObjectIds = contactIDArray;
    massRequest.replyTo = replyTo;
    massRequest.subject = 'RE:'+ '{!Case.Subject}';
    massRequest.templateId = templateId;
    var sendMailRes =  sforce.connection.sendEmail([massRequest]);
}


can anyone help me to achive this?

thanks in advance.

Message Edited by Naresh on 05-23-2007 12:23 AM

Message Edited by Naresh on 05-23-2007 12:31 AM