this is the vb.net coding .......
note:- this is the coding which uses the gmail smtp server, u need to enter the valid email id and password of gmail, then only this will work...
if u have any pblm then ask me any time...
my id is:- k.ashish237@gmail.com
Imports System.Net.Mail
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim MyMailMessage As New MailMessage()
MyMailMessage.From = New MailAddress("sender email")
MyMailMessage.To.Add(TextBox1.Text)
MyMailMessage.Subject = "subject title"
MyMailMessage.Body = "enter the body text message that u want to send"
For counter = 0 To ListBox1.Items.Count - 1
Dim Attach As Net.Mail.Attachment = New Net.Mail.Attachment(ListBox1.Items(counter))
MyMailMessage.Attachments.Add(Attach)
Next
Dim SMTPServer As New SmtpClient("smtp.gmail.com")
SMTPServer.Port = 587
SMTPServer.Credentials = New System.Net.NetworkCredential("yourid@gmail.com", "id password")
SMTPServer.EnableSsl = True
Try
SMTPServer.Send(MyMailMessage)
MessageBox.Show("Email Sent")
Catch ex As SmtpException
MessageBox.Show(ex.Message)
End Try
End Sub
same coding with the tools of vb.net......
hope this will help u....
Imports System.Net.Mail
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim MyMailMessage As New MailMessage()
MyMailMessage.From = New MailAddress(TextBox3.Text)
MyMailMessage.To.Add(TextBox1.Text)
MyMailMessage.Subject = TextBox2.Text
MyMailMessage.Body = RichTextBox1.Text
For counter = 0 To ListBox1.Items.Count - 1
Dim Attach As Net.Mail.Attachment = New Net.Mail.Attachment(ListBox1.Items(counter))
MyMailMessage.Attachments.Add(Attach)
Next
Dim SMTPServer As New SmtpClient("smtp.gmail.com")
SMTPServer.Port = 587
SMTPServer.Credentials = New System.Net.NetworkCredential(TextBox4.Text, TextBox5.Text)
SMTPServer.EnableSsl = True
Try
SMTPServer.Send(MyMailMessage)
MessageBox.Show("Email Sent")
Catch ex As SmtpException
MessageBox.Show(ex.Message)
End Try
End Sub