Try this code which is helpful for you.
Code:
Invoke the Code widow and type the following statement above the Class declaration
Imports System.Web.Mail
Within the Class declaration, in the general section declare variables required for this project
' Variable which will send the mail
Dim obj As System.Web.Mail.SmtpMail
'Variable to store the attachments
Dim Attachment As System.Web.Mail.MailAttachment
'Variable to create the message to send
Dim MailMsgg As New System.Web.Mail.MailMessage()
Double click on the addattachment button to add the code
Type the following lines
'Show open dialogue box to select the files to attach
Dim Counter As Integer
OFD.CheckFileExists = True
OFD.Title = "Select file(s) to attach"
OFD.ShowDialog()
For Counter = 0 To UBound(OFD.FileNames)
lstAttachment.Items.Add(OFD.FileNames(Counter))
Next
Double Click on the Removeattachment button
Type the following lines
'Remove the attachments
If lstAttachment.SelectedIndex > -1 Then
lstAttachment.Items.RemoveAt(lstAttachment.SelectedIndex)
End If
Double Click on the Send button
Type the following lines
Dim Counter As Integer
'Validate the data
If txtSMTPServer.Text = "" Then
MsgBox("Enter the SMTP server info ...!!!", MsgBoxStyle.Information, "Send Email")
Exit Sub
End If
If txtFrom.Text = "" Then
MsgBox("Enter the From email address ...!!!", MsgBoxStyle.Information, "Send Email")
Exit Sub
End If
If txtTo.Text = "" Then
MsgBox("Enter the Recipient email address ...!!!", MsgBoxStyle.Information, "Send Email")
Exit Sub
End If
If txtSubject.Text = "" Then
MsgBox("Enter the Email subject ...!!!", MsgBoxStyle.Information, "Send Email")
Exit Sub
End If
'Set the properties
‘Assign the SMTP server
obj.SmtpServer = txtSMTPServer.Text
'Multiple recepients can be specified using ; as the delimeter
‘Address of the recipient
MailMsgg.To = txtTo.Text
‘Your From Address
‘You can also use a custom header Reply-To for a different replyto address
MailMsgg.From = "" & txtFromDisplayName.Text & " <" & txtFrom.Text & ">"
'Specify the body format
If chkFormat.Checked = True Then
MailMsgg.BodyFormat = MailFormat.Html 'Send the mail in HTML Format
Else
MailMsgg.BodyFormat = MailFormat.Text
End If
'If you want you can add a reply to header
'MailMsgg.Headers.Add("Reply-To", "Manoj@geinetech.net")
'custom headersare added like this
'MailMsgg.Headers.Add("Manoj", "TestHeader")
‘Mail Subject
MailMsgg.Subject = txtSubject.Text
‘Attach the files one by one
For Counter = 0 To lstAttachment.Items.Count - 1
Attachment = New MailAttachment(lstAttachment.Items(Counter))
‘Add it to the mail message
MailMsgg.Attachments.Add(Attachment)
Next
‘Mail Body
MailMsgg.Body = txtMessage.Text
‘Call the send method to send the mail
obj.Send(MailMsgg)
Bookmarks