function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ 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?