You need to sign in to do that
Don't have an account?
Ram Chaturvedi
Error: Compile Error: line 16:0 no viable alternative at character ' ' at line 16 column 0 ?
trigger FireMail on Lead__c (after insert,after update) {
list<lead__c> leads = new list<lead__c>();
string mailcontent ;
leads = trigger.new ;
for(lead__c ld : leads){
string nm = ld.name ;
string EmailId = ld.Email_Id__c ;
if(EmailId != null){
mailcontent ='Thanks For contacting Us ' ;
// here error is Occur
Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
string [] toaddress= New string[]{EmailId};
email.setSubject('Thanks for Contacting .');
email.setPlainTextBody(mailcontent);
email.setToAddresses(toaddress);
Messaging.sendEmail(New Messaging.SingleEmailMessage[]{email});
}
}
}
list<lead__c> leads = new list<lead__c>();
string mailcontent ;
leads = trigger.new ;
for(lead__c ld : leads){
string nm = ld.name ;
string EmailId = ld.Email_Id__c ;
if(EmailId != null){
mailcontent ='Thanks For contacting Us ' ;
// here error is Occur
Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
string [] toaddress= New string[]{EmailId};
email.setSubject('Thanks for Contacting .');
email.setPlainTextBody(mailcontent);
email.setToAddresses(toaddress);
Messaging.sendEmail(New Messaging.SingleEmailMessage[]{email});
}
}
}
https://developer.salesforce.com/forums/ForumsMain?id=906F0000000938oIAA
Regards
1. You are storing trigger.new in List variable and then you are using that in your for loop. Instead you can directly use the trigger.New in the for looping which will helps to reduce the heap size in the execution.
2. You are sending email inside the for loop by which you will easily hit an number of email governor limit.
Try th updated code below
But
i had delete the single quotes, retype again but its giving error .... :-(