This is my code to send lots of emails. I want to optimize this code to be sure that it will work and can successfully send all emails. What should I do? I know that putting interrupts between sending might be useful but how can I do this?
The main problem is avoiding classify emails as spam and decreasing number of failed sent emails.
var list = from c in context.Emails orderby c.EmailAddress select c.EmailAddress;
MailMessage mail = new MailMessage();
try
{
    mail.From = new MailAddress(txtfrom.Text);
    foreach (var c in list)  
    {  
        mail.To.Add(new MailAddress(c.ToString()));
    }
    mail.Subject = txtSub.Text;
    mail.IsBodyHtml = true;
    mail.Body = txtBody.Text;
    if (FileUpload1.HasFile)
    {
        mail.Attachments.Add(new Attachment(
           FileUpload1.PostedFile.InputStream, FileUpload1.FileName));
    }
    SmtpClient smtp = new SmtpClient();
    smtp.Send(mail); 
}
catch (Exception)
{
    //exception handling
}
 
     
     
    