Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Problem deleting mail attachment

Problem deleting mail attachment

Scheduled Pinned Locked Moved ASP.NET
helpcsharpasp-netcomsysadmin
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    NetBot
    wrote on last edited by
    #1

    Hi all, i m sending mails using Asp.net 2.0 Here is my code Sub SendMail() Dim msg As New MailMessage() Dim attach_file1 As String = String.Empty Dim strfilename As String = String.Empty Dim strpath As String = Request.ApplicationPath & "/" & "Attachments" & "/" strfilename = Path.GetFileName(UploadCV.PostedFile.FileName) UploadCV.PostedFile.SaveAs(Server.MapPath(strpath & strfilename)) Dim attach As New Attachment(Server.MapPath(strpath & strfilename)) msg.Attachments.Add(attach) attach_file1 = strfilename Dim smtpclnt As New SmtpClient() Dim ds1 As New DataSet() ds1 = CType(Session("Dataset"), DataSet) msg.Subject = "You have successfully applied for the post of " & ds1.Tables(0).Rows(0).Item(2).ToString() msg.Body = "Hi all" 'msg.To.Add(ds1.Tables(0).Rows(0).Item(9)) msg.To.Add("somemail@gmail.com") msg.From = New MailAddress(Session("emailid").ToString()) smtpclnt.Send(msg) If attach_file1 <> "" Then File.Delete(Server.MapPath(strpath & strfilename)) End If End Sub but it gives me exception at File.Delete(Server.MapPath(strpath & strfilename)) and it says The process cannot access the file (filepath) because it is being used by another process. any idea abt this error?

    modified on Sunday, July 17, 2011 2:38 PM

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups