Windows App. Vb.net 2008
I have a form to send mail using gmail id with attachments
what i am doing is i am sending my zip file to gmail id ,
now i want to show a progress bar to user when sending mail and after
send mail i want to show a msg Like Success as boolean , mail send or not
here is my code to send mail.
========
Imports System.Net.Mail
Public Class FrmSendMail
Dim mail As New MailMessage()
Private Sub FrmSendMail_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.ProgressBar1.MarqueeAnimationSpeed = 0
txtsubj.Text = "Sending Data"
txtfrom.Text = "nagcm2brd@gmail.com"
txtto.Text = "nagcm1hyd@gmail.com"
Dim pwd As String
pwd = "ayub1234"
If InternetConnection() = False Then
MessageBox.Show("No internet connection!", "Connecting to Internet", MessageBoxButtons.OK, MessageBoxIcon.Error)
Me.Btnclose_Click(sender, e)
Else
MessageBox.Show("Internet connection detected!", "Connecting to Internet", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
End Sub
Private Sub sendml()
Dim SmtpServer As New SmtpClient()
SmtpServer.Credentials = New Net.NetworkCredential("nagcm2brd@gmail.com", "ayub1234")
SmtpServer.Port = 587
SmtpServer.Host = "smtp.gmail.com"
SmtpServer.EnableSsl = True
mail = New MailMessage()
Dim addr() As String = txtto.Text.Split(",")
Try
mail.From = New MailAddress("nagcm2brd@gmail.com", "Baroda Data", System.Text.Encoding.UTF8)
Dim i As Byte
For i = 0 To addr.Length - 1
mail.To.Add(addr(i))
Next
mail.Subject = txtsubj.Text
mail.Body = txtmsg.Text
If ListBox1.Items.Count <> 0 Then
For i = 0 To ListBox1.Items.Count - 1
mail.Attachments.Add(New Attachment(ListBox1.Items.Item(i)))
Next
End If
mail.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure
mail.ReplyTo = New MailAddress(txtto.Text)
SmtpServer.Send(mail)
Catch ex As Exception
MsgBox(ex.ToString())
End Try
End Sub
Private Sub BtnSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnSend.Click
sendml()
End Sub
End Class
========
Any Help will be highly appreciated.
Thanks in advance.