function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
NareshNaresh 

Not able to attch case fields in email template with sendMail functionality

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

Ron HessRon Hess
I suspect that the template has a subject which is used rather than the subject you specify.

is there a subject in the template?
what subject comes out in the emails ?


also, (may not matter) it looks like you are using mailRequest as a variable AND an array, i normaly use this form:

var result = sforce.connection.sendEmail( [ mailRequest ] );
NareshNaresh
Thanks for response....

I have tried this also, but its not working with any template.
NareshNaresh
Hi,
      when i specify any static subject in the template then it's working fine. But it's not working when i get subject from any Case object subject. The sending email have blank subject .

Thanks,
Rasmus MenckeRasmus Mencke
I the MassEmailMessage call you can not set the "what" context; it is currently not supported in the API.

The API is designed around the Mass Email capability in the app, which doesn't let you set the context of the object, like it is possible with SingleEmails.

You can use SingleEmailMessage to send out the emails.

It is not possible to overwrite the subject line from the template in the API, the subject specified when setting up the template is being used, eventhough the API lets you specify a subject.



skpskp

I am very keen to know how you could solve your problem using SingleEmailMessage, in place of MassEmailMessage OR what workaround you used

I have a similar situation where I want to use a Template and that containes some CustomObject values in the form of {!CustomObject__c.SomeInfo__c}. How can I evaluate such object references using SingleEmailMessage?

I don't want to hard code {!CustomObject__c.SomeInfo__c}.  entries in the S-Control itself as that would incur future maintenance overhead.