hey all!
i would like in my program to send an attachment file in the mail. so i managed to to this but after this i would like to acess the file again ,change somthing there and send it again.
this is the code:
Code:
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim SmtpServer As New SmtpClient()
SmtpServer.Credentials = New Net.NetworkCredential("user.com ", "dsasd2321d")
SmtpServer.Port = 25
SmtpServer.Host = "smtp.gmail.com"
SmtpServer.EnableSsl = True
Dim omail As New MailMessage()
omail.From = New MailAddress("user.com", "aaa", System.Text.Encoding.UTF8)
omail.Subject = "test subject"
omail.To.Add("iaasd@gmail.com")
Dim attachFile As New Attachment("c:\bit32\bit.text")
omail.Attachments.Add(attachFile)
SmtpServer.SendAsync(omail, Nothing)
MsgBox("emails")
IO.File.AppendAllText("c:\bit32\bit.text", "blbalbablba")
End Sub
End Class
i know how to send a mail with attachment,thats not the point.. the point is i think i need to close the file because when its getting to this line: IO.File.AppendAllText("c:\bit32\bit.text", "blbalbablba")
there is an error which telling me i cant acess the file because its aleardy open by another proccesss... ther is any file.close command or somthing?
can any1 help me plz? its very important .. thank u very much
i would like in my program to send an attachment file in the mail. so i managed to to this but after this i would like to acess the file again ,change somthing there and send it again.
this is the code:
Code:
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim SmtpServer As New SmtpClient()
SmtpServer.Credentials = New Net.NetworkCredential("user.com ", "dsasd2321d")
SmtpServer.Port = 25
SmtpServer.Host = "smtp.gmail.com"
SmtpServer.EnableSsl = True
Dim omail As New MailMessage()
omail.From = New MailAddress("user.com", "aaa", System.Text.Encoding.UTF8)
omail.Subject = "test subject"
omail.To.Add("iaasd@gmail.com")
Dim attachFile As New Attachment("c:\bit32\bit.text")
omail.Attachments.Add(attachFile)
SmtpServer.SendAsync(omail, Nothing)
MsgBox("emails")
IO.File.AppendAllText("c:\bit32\bit.text", "blbalbablba")
End Sub
End Class
i know how to send a mail with attachment,thats not the point.. the point is i think i need to close the file because when its getting to this line: IO.File.AppendAllText("c:\bit32\bit.text", "blbalbablba")
there is an error which telling me i cant acess the file because its aleardy open by another proccesss... ther is any file.close command or somthing?
can any1 help me plz? its very important .. thank u very much