You need to sign in to do that
Don't have an account?
sailer
SendEmail failed. First exception on row 0; first error:Maximum stack depth reached: 2:
Hi All,
I have created the Email Template by using the component and trying to send the mail through the scheduled apex
EMAIL Template
<messaging:emailTemplate subject="Remainder FollowUp" recipientType="User" relatedToType="Property_Obj__c" >
<messaging:htmlEmailBody >
<c:RemainderMailC AcctId="{!relatedTo.Id}" />
Regard
{!recipient.Name}
</messaging:htmlEmailBody>
</messaging:emailTemplate>
Component:
<apex:component controller="acctTemplt" access="global">
<apex:attribute name="AcctId" type="Id" description="Id of the account" assignTo="{!conID}"/>>
<apex:repeat value="{!opptys}" var="o">
{!o.Name}
{!o.Id}
</apex:repeat>
</apex:component>
Apex Class
public class acctTemplt
{
public Id conID {get;set;}
public List<Property_Obj__c> usr{get;set;}
//
public List<Property_Obj__c> Ids{get;set;}
public List<String> usr_email{get;set;}
public Map<string,string> Map_usr{get;set;}
public List<Property_Obj__c> getopptys()
{
/*
List<Property_Obj__c> oppty;
oppty = [select Id, Status__c,Name,Mail_Response__c,Listing_Sales_Associate_Email__c from Property_Obj__c where Mail_Response__c=true AND Id =:conID ];
return oppty;
*/
usr=new List<Property_Obj__c>();
usr_email=new List<String>();
usr.clear();
usr_email.clear();
Ids=[Select id from Property_Obj__c];
System.debug('Id of the property___________________________'+Ids);
usr=[select Id, Status__c,Name,Mail_Response__c,Listing_Sales_Associate_Email__c from Property_Obj__c where Mail_Response__c=true AND Id=:Ids LIMIT 1];
System.debug('Query Retrived___________________________________'+usr);
Map_usr=new Map<string,string>();
for(Property_Obj__c u:usr)
{
system.debug('__id______'+u.id+'___________Email______'+u.Listing_Sales_Associate_Email__c+'_________DATE_____'+u.Status__c);
Map_usr.put(u.id,u.Listing_Sales_Associate_Email__c);
if(u.Listing_Sales_Associate_Email__c!=null)
usr_email.add(u.Listing_Sales_Associate_Email__c);
}
if(usr_email != null && usr_email.size() > 0)
{
System.debug('Size of the List Mail__________________ '+ usr_email.size());
sendmail(usr_email);
}
return usr;
}
public void sendmail(List<String> str)
{
EmailTemplate et = [SELECT id,HtmlValue,Body,Subject ,Name FROM EmailTemplate WHERE Name = 'RemainderMailVF'];
Messaging.Singleemailmessage email = new Messaging.Singleemailmessage();
String [] toaddress=str;
String[] ccAddresses=new String[]{'veluri.harani@gmail.com'};
email.setTemplateId('00XS0000000MPu9');
email.setTargetObjectId('005800000059yaE');
email.setSaveAsActivity(false);
email.setToAddresses(toaddress);
email.setCcAddresses(ccAddresses);
Messaging.sendEmail(new Messaging.Singleemailmessage[] { email });
}
}
scheduled Apex Job.
global class RemainderMailFrequency implements Schedulable
{
global void execute(SchedulableContext ctx)
{
acctTemplt acct = new acctTemplt();
acct.getopptys();
acct.sendmail(str);
System.debug('The Size of batch calss');
}
}
Pl help me out i am struck here .
Regards
Sailer
I have created the Email Template by using the component and trying to send the mail through the scheduled apex
EMAIL Template
<messaging:emailTemplate subject="Remainder FollowUp" recipientType="User" relatedToType="Property_Obj__c" >
<messaging:htmlEmailBody >
<c:RemainderMailC AcctId="{!relatedTo.Id}" />
Regard
{!recipient.Name}
</messaging:htmlEmailBody>
</messaging:emailTemplate>
Component:
<apex:component controller="acctTemplt" access="global">
<apex:attribute name="AcctId" type="Id" description="Id of the account" assignTo="{!conID}"/>>
<apex:repeat value="{!opptys}" var="o">
{!o.Name}
{!o.Id}
</apex:repeat>
</apex:component>
Apex Class
public class acctTemplt
{
public Id conID {get;set;}
public List<Property_Obj__c> usr{get;set;}
//
public List<Property_Obj__c> Ids{get;set;}
public List<String> usr_email{get;set;}
public Map<string,string> Map_usr{get;set;}
public List<Property_Obj__c> getopptys()
{
/*
List<Property_Obj__c> oppty;
oppty = [select Id, Status__c,Name,Mail_Response__c,Listing_Sales_Associate_Email__c from Property_Obj__c where Mail_Response__c=true AND Id =:conID ];
return oppty;
*/
usr=new List<Property_Obj__c>();
usr_email=new List<String>();
usr.clear();
usr_email.clear();
Ids=[Select id from Property_Obj__c];
System.debug('Id of the property___________________________'+Ids);
usr=[select Id, Status__c,Name,Mail_Response__c,Listing_Sales_Associate_Email__c from Property_Obj__c where Mail_Response__c=true AND Id=:Ids LIMIT 1];
System.debug('Query Retrived___________________________________'+usr);
Map_usr=new Map<string,string>();
for(Property_Obj__c u:usr)
{
system.debug('__id______'+u.id+'___________Email______'+u.Listing_Sales_Associate_Email__c+'_________DATE_____'+u.Status__c);
Map_usr.put(u.id,u.Listing_Sales_Associate_Email__c);
if(u.Listing_Sales_Associate_Email__c!=null)
usr_email.add(u.Listing_Sales_Associate_Email__c);
}
if(usr_email != null && usr_email.size() > 0)
{
System.debug('Size of the List Mail__________________ '+ usr_email.size());
sendmail(usr_email);
}
return usr;
}
public void sendmail(List<String> str)
{
EmailTemplate et = [SELECT id,HtmlValue,Body,Subject ,Name FROM EmailTemplate WHERE Name = 'RemainderMailVF'];
Messaging.Singleemailmessage email = new Messaging.Singleemailmessage();
String [] toaddress=str;
String[] ccAddresses=new String[]{'veluri.harani@gmail.com'};
email.setTemplateId('00XS0000000MPu9');
email.setTargetObjectId('005800000059yaE');
email.setSaveAsActivity(false);
email.setToAddresses(toaddress);
email.setCcAddresses(ccAddresses);
Messaging.sendEmail(new Messaging.Singleemailmessage[] { email });
}
}
scheduled Apex Job.
global class RemainderMailFrequency implements Schedulable
{
global void execute(SchedulableContext ctx)
{
acctTemplt acct = new acctTemplt();
acct.getopptys();
acct.sendmail(str);
System.debug('The Size of batch calss');
}
}
Pl help me out i am struck here .
Regards
Sailer
Please go through this thread and edit your code accordingly:
https://developer.salesforce.com/forums/ForumsMain?id=906F000000092jvIAA