Now Error in Sending
wht i want that works . but my email sending code is nt working now...preivously it was working because i was using this piec of code.....
Private Sub DataGridView1_CellClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellClick
If e.ColumnIndex = 1 Then
If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
DataGridView1.CurrentCell.Value = OpenFileDialog1.FileName
End If
End If
End Sub
but whn i relace it with the code u had provided that is...
Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button11.Click
If FolderBrowser1.ShowDialog = Windows.Forms.DialogResult.OK Then
For Each PdfDocument As String In IO.Directory.GetFiles(FolderBrowser1.SelectedPath, "*.pdf")
Dim file As New IO.FileInfo(PdfDocument)
DataGridView1.Rows.Add(False, PdfDocument, String.Empty, file.Name.Replace(file.Extension, ""), String.Empty)
Next
End If
End Sub
It view me all the file from the folder to datagrideview,but now i am nt able to send that checked file,it give me out error("Smtp Error: You supplied incorrect information, please check supplied information.")..i am using this code to send the checked item,..
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
For Each row As DataGridViewRow In DataGridView1.Rows
If Not CType(row.Cells(0), DataGridViewCheckBoxCell).Value = CType(row.Cells(0), DataGridViewCheckBoxCell).TrueValue Then
Dim FileName As String = row.Cells(1).Value
Dim EmailAddress As String = row.Cells(2).Value
Try
Dim subject, username, password, body, server, portnumber As String
portnumber = TextBox8.Text
subject = TextBox1.Text
username = TextBox4.Text
password = TextBox5.Text
body = TextBox3.Text
server = TextBox6.Text
Dim smtpserver As New SmtpClient()
Dim mail As New MailMessage()
Dim mailat As New Attachment(FileName)
smtpserver.Credentials = New Net.NetworkCredential(username, password)
smtpserver.Port = portnumber
smtpserver.Host = server
smtpserver.EnableSsl = True
mail = New MailMessage()
mail.From = New MailAddress(username)
mail.To.Add(EmailAddress)
mail.Subject = subject
mail.Attachments.Add(mailat)
mail.Body = body
smtpserver.Send(mail)
MsgBox("Message Sent Successfully", MsgBoxStyle.Information)
Catch ex As Exception
MsgBox("Smtp Error: You supplied incorrect information, please check supplied information.", MsgBoxStyle.Critical)
End Try
End If
Next
End Sub
plz let me know where do i get wrong.....plz help me out i am almost done with my acedimic project only this part is remain...plz help me out....