The process cannot access the file because it is being used by another process

Posted by Xenon on Stack Overflow See other posts from Stack Overflow or by Xenon
Published on 2010-05-12T08:11:19Z Indexed on 2010/05/12 8:24 UTC
Read the original article Hit count: 328

Filed under:
|
|
|
|

I have an asp.net website and I allready did .Dispose() here is my code below;

try {

        MailMessage newMail = new MailMessage(MailFrom, MailTo,

MailSubject, MailMsg);

        if (MailAttachment != "")
        {
            Attachment data = new Attachment(MailAttachment,

MediaTypeNames.Application.Octet); newMail.Attachments.Add(data); } newMail.BodyEncoding = System.Text.Encoding.UTF8; newMail.IsBodyHtml = true;

        SmtpClient client = new SmtpClient("192.168.2.205");
        client.Credentials = CredentialCache.DefaultNetworkCredentials;
        client.Send(newMail);

        newMail.Attachments.Dispose();
        newMail.Dispose();

        DeleteAttachment(MailAttachment);

        lblSuccess.Text = "Basvurunuz alinmistir tesekkürler.";
        lblSuccess.Visible = true;
        ClearForm();
    }
    catch (Exception ex)
    {
        lblSuccess.Text = ex.Message;
        //lblSuccess.Text = "Bir sorun olustu bir daha deneyiniz.";
        lblSuccess.Visible = true;
    }

But i' m getting the same error, it' s running fine in my localhost but in server i' m getting this error. How can i fix it?

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about c#