+ Start a Discussion
Mani PenumarthiMani Penumarthi 

sending an email

hi every one,

i wrote this code and email was not coming and no error is genereating. in debug logs it is showing th eemail id,

can u help me i want to send email 

 

public class custom_deletetask
{


public custom_deletetask()
{
List<CustomTask__c> li=[select Assigned_To_name__c,Assigned_To__c,Boolean__c,Description__c,Due_Date__c,DueText__c,E_mail__c,OpenBoolean__c,OrganizationName__c,Organization_Name__c,Priority__c,Status__c,Subject__c,Task_Assigned_To__c from CustomTask__c where Status__c='Completed' limit 100];

System.debug('*******'+li);


System.debug('Email added succesfuullly');
Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
string [] toaddress= New string[]{'chiru.ganta@gmail.com'};
email.setSubject('Expired tasks');
email.setHtmlBody('<html>' + '<i>LivaitApp</i>' + '<h4>'+'Hello :'+'</h4>'+ 'Deleted tasks are'+ '<br/>'+'<br/>' +'<body align="center">'+'<table border="2" align="center">' + '<th><u>SUBJECT</u></th>' + '<th><u>PRIORITY</u></th>' + '<th><u>Organization</u></th>' + '<th><u>To Know Details</u></th>' + '<tr align="center">' + '</tr>' + '<td>'+'li.subject__c'+'</td>'+'</table>' + '</body>' + '</html>');
email.setToAddresses(toaddress);
Messaging.sendEmail(New Messaging.SingleEmailMessage[]{email});
System.debug('Sent Mail to '+toaddress);
// }
// }
}
}

Scott_VSScott_VS

The email came through just fine for me.

 

Are you sure that the message is not going to your spam filter?

Anup JadhavAnup Jadhav

Try sending it to a different (non-gmail) address, and see if it works.

 

- anup