+ Start a Discussion
Abhijeet Purohit01Abhijeet Purohit01 

Problem in sending email

I have used the following statement to send an email


Messaging.SingleEmailMessage email1 = new Messaging.SingleEmailMessage()



For this I have created a dummy record in the Contact object


 Contact c = new Contact( AccountId = accId,LastName = 'Testa',Email='abhijeet.p@algypug.com',CurrencyIsoCode = 'INR',MobilePhone = '9886098860',Credit_Report__c = 'NO');
   insert c;

Now after sending the email I delete this record as below:


Messaging.SendEmailResult [] r =  Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email1});
delete c;   



The problem here is this record is not getting deleted. Due to this I have created some 50+ dummy records in the Contact object.

Where am I wrong?