Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: VB.NET
Windows App. 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 = ""
        txtto.Text = ""
        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)
            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("", "ayub1234")
        SmtpServer.Port = 587
        SmtpServer.Host = ""
        SmtpServer.EnableSsl = True
        mail = New MailMessage()
        Dim addr() As String = txtto.Text.Split(",")
            mail.From = New MailAddress("", "Baroda Data", System.Text.Encoding.UTF8)
            Dim i As Byte
            For i = 0 To addr.Length - 1
            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)))
            End If
            mail.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure
            mail.ReplyTo = New MailAddress(txtto.Text)

        Catch ex As Exception
        End Try
    End Sub
 Private Sub BtnSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnSend.Click
    End Sub
End Class
Any Help will be highly appreciated.
Thanks in advance.
Posted 15-Feb-12 22:32pm
Edited 15-Feb-12 22:33pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

a small google search leads to this[^].
gufran90 at 16-Feb-12 3:44am
Thanks for your reply , @digimanus
i have read the msdn link but its ,
showing answer with third party tool ( )
is there any way to do with only
waiting for your reply.
Thanks in advance
digimanus at 16-Feb-12 3:50am
without that component it lloks like it cannot be done.
Progressbar is only useful when sending large attachments.
Other optios is sending a stream to a socket. The stream can can be send in parts and counting the parts leads to a percentage.
gufran90 at 16-Feb-12 4:14am
Thanks for your quick response @digimanus ,
ok , leave progress bar ,
i want to confirm to user the mail was send or not ,
how can i do that .
thanks is advance
waiting for your reply.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Where is InternetConnection()funtion's method?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Advertise | Privacy | Mobile
Web01 | 2.8.150129.1 | Last Updated 7 Nov 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100