• sureshcsk
  • NEWBIE
  • 0 Points
  • Member since 2009

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 3
    Replies

Hi.

 

1.In Contact object created a custome field called Group.

 

Group values like A,B,C..

 

2.I queried the email id from the Contact object according to user Group reguest.

Let us consider we took all email ids related to Group A.

 

public List<String> email_list;

public List<Contact> emailaddress;

 

 

emailaddress = new List<Contact>();

 


/******* get all email address related to Group *******/

 

emailaddress = [Select email From Contact Where Contact.group__c =:groupvalue];

no_ofemail = integer.valueOf(emailadd.size());
email_list = new String[no_ofemail];

 

 

 /******* added all the retrieved  email address to a String list email_list*******/

 

 for( Contact tempemail : emailaddress)
        {
        email_list[i] =tempemail.email;
        i++;
        }  

 

3.Sending email to Group A members

 

Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
mail.setbccAddresses(email_list);
mail.setSubject(template_subject);
mail.setPlainTextBody(template_body);
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });

 

 

I used only SingleEmailMessage() but email is sent to all

the email address which exists in the email_list <List>.

 

Then whats the difference between  SingleEmailMessage and MassEmailMessage.

 

 

 

 

 

 

 

I created a custom field (Contact_ID)in Contacts.Then developed a login VF page

and logged in using the Contact_ID  . After logging a form comes, the user fills and

sumbit to Case.

 

Issue:

 

When user sumbitting  the form to Case ,I am able to  insert a new case to Cases,but

not able to insert only  the Contact Name field in Case.I queried the corresponding last name

from Contact using the Contact_ID which the user used for logging.

 

I saw the "Contact Name" field in Case is a parent-child relationship.I will really

appreciate any idea for this issue.

 

regards

suresh

 

 

 

 

 

 

 

Hi.

 

1.In Contact object created a custome field called Group.

 

Group values like A,B,C..

 

2.I queried the email id from the Contact object according to user Group reguest.

Let us consider we took all email ids related to Group A.

 

public List<String> email_list;

public List<Contact> emailaddress;

 

 

emailaddress = new List<Contact>();

 


/******* get all email address related to Group *******/

 

emailaddress = [Select email From Contact Where Contact.group__c =:groupvalue];

no_ofemail = integer.valueOf(emailadd.size());
email_list = new String[no_ofemail];

 

 

 /******* added all the retrieved  email address to a String list email_list*******/

 

 for( Contact tempemail : emailaddress)
        {
        email_list[i] =tempemail.email;
        i++;
        }  

 

3.Sending email to Group A members

 

Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
mail.setbccAddresses(email_list);
mail.setSubject(template_subject);
mail.setPlainTextBody(template_body);
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });

 

 

I used only SingleEmailMessage() but email is sent to all

the email address which exists in the email_list <List>.

 

Then whats the difference between  SingleEmailMessage and MassEmailMessage.

 

 

 

 

 

 

 

Is there a way to render the merge fields in a string in Apex. As an example, I want to use email templates for a task. I've
written a VF page to override new task creation. It has a function that retrieves the body of the template but when its displayed
in the inputField it show the merge field syntax; i.e. Dear {!Contact.FirstName}.

 

public PageReference changeTemplate() {
EmailTemplate template = [Select TemplateType, Subject,
Name, Id, HtmlValue, Body, Description From EmailTemplate where id =:ApexPages.currentPage().getParameters().get('templateId')];

msg.Subject__c = template.Subject;
msg.Description__c = template.Body; //includes {!merge fields} as literal
}
return null ;
}

 

 I'm not sending an email as part of this process, so I need some way to render the merge fields in the string. What complicates this is that while the whoId can only be a Lead or Contact, the whatId on the task can any object. So a simple find and replace on the string gets very complex. Any suggestions?
Hi,
 
We need to use salesforce email templates from a trigger or Apex class. The template has most of the merge fields from a custom object named "Assignment__c" and the email needs to be sent to the custom email field in another custom object named "Contractor__c".
 
Is this possible using the following code snippet?  We tried it but was throwing exception saying that it supports only standard objects by Users, Lead and Contacts.
 
   mail.setTemplateId(templateId);
   mail.setTargetObjectId ('01I700000002M9A');
   mail.setWhatId(AssignmentId);
 
Any help or guidelines with some sample code on how this can be done will be greatly appreciated. Thanks and let me know if you need any other information.
 
Regards,
Rasu
  • November 20, 2008
  • Like
  • 0