Know when mail is sent (using smtpclient in c#)

I am using SMTPClient to send e-mail with a textfile as an attachment

My Code is
      System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient(sSmtp);

This works fine however I need to know when the mail is sent to be able to move the text file attachment with out getting the error that the file is being used by another process.

How can I do this?
Who is Participating?
Die-TechConnect With a Mentor Commented:
Just like adding an event handler for any other object:
smtp.SendCompleted += new SendCompletedEventHandler(EmailSendCompleted);

That'll create method like this where you can do whatever you want:
private void EmailSendCompleted(object sender, AsyncCompletedEventArgs e)
   // delete my attachments or whatever
Add an event handler to the SendCompleted event.
dbdpAuthor Commented:
how do I do that?
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.