how can i email document ?

suju_26pro

Well-known member
Joined
May 4, 2011
Messages
48
Programming Experience
Beginner
Thnx a lot Joshdbr, with help u i can however manage to make my application run...thnx a lot .....

Now can u suggest me how can i email the checked document to a specific email id, i want to use pop3 for this, plz provide code if u can ..thnx once again...
 
Last edited by a moderator:
What do you mean by cell? Also, this might require a new thread if it is not on the subject of emailing.
 
What do you mean by the other view?
 
Sure, if I knew what you were talking about :)
 
i want in this way...where all pdf file from selected folder in listed , the user wil check which file he want to sign , then he willl sign and if he want to email the document then he will provide and email id for it...i want the same way the pics lookk...plz help ne out...:confused:
 

Attachments

  • Untitled.jpg
    Untitled.jpg
    59.6 KB · Views: 39
OK, I see what you are wanting now, but you will have to start a new thread :) sorry.
 
Ok then. Remove the OpenFile DIalog from there and drag and drop a FolderBrowser Dialog!

Then just add this code to Input Folder BROWSE Button:


   Private Sub InputBrowseButton_Click(sender As System.Object, e As System.EventArgs) Handles InputBrowseButton.Click
        If FolderBrowserDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            For Each PdfDocument As String In IO.Directory.GetFiles(FolderBrowserDialog1.SelectedPath, "*.pdf")
                DataGridView1.Rows.Add(False, PdfDocument, String.Empty)
            Next
        End If
    End Sub

     
 
Ups i didn't see that now you have an extra column. Use the following code instead:
        If FolderBrowserDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            For Each PdfDocument As String In IO.Directory.GetFiles(FolderBrowserDialog1.SelectedPath, "*.pdf")
                Dim file As New IO.FileInfo(PdfDocument)
                DataGridView1.Rows.Add(False, PdfDocument, file.Name.Replace(file.Extension, ""), String.Empty)
            Next
        End If


Or even better:
       If FolderBrowserDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            For Each PdfDocument As String In IO.Directory.GetFiles(FolderBrowserDialog1.SelectedPath, "*.pdf")
                DataGridView1.Rows.Add(False, PdfDocument, IO.Path.GetFileNameWithoutExtension(PdfDocument), String.Empty)
            Next
        End If
 
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....:confused:
 
Where and what is the error?
 
i am getting an exception error..
MsgBox("Smtp Error: You supplied incorrect information, please check supplied information.", MsgBoxStyle.Critical)
 
Catch ex As Exception
MsgBox("Smtp Error:
You can't catch any kind of Exception and show that message. Look at the ex.Message.
The types of exceptions the Send method may throw is listed in documentation, and as you can see there can be all kinds of reasons: SmtpClient.Send Method (MailMessage) (System.Net.Mail)
Any other operation in that Try code block could also be the cause of the Exception.

Relevant for debugging is also the actual type of exception, call stack and line number, the actual error message and all the before mentioned information included if you do a ex.ToString, so you should post a quote of this output here and explain what line threw the exception. This is not something you show to the user, the ex.Message would probably be relevant, but for your own debugging and to get help here at forums you should provide this information.
 
Back
Top