Click here to Skip to main content
12,076,727 members (45,665 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: VB VB.NET
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.
Posted 15-Feb-12 22:32pm
Edited 15-Feb-12 22:33pm
digimanus46.5K
v2
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

a small google search leads to this[^].
  Permalink  
Comments
gufran90 16-Feb-12 3:44am
   
Thanks for your reply , @digimanus

i have read the msdn link but its ,
showing answer with third party tool ( Chilkat.net )

is there any way to do with vb.net only

waiting for your reply.

Thanks in advance
digimanus 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 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
 
good
Please Sign up or sign in to vote.

Solution 2

Where is InternetConnection()funtion's method?
  Permalink  

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web01 | 2.8.160212.1 | Last Updated 7 Nov 2013
Copyright © CodeProject, 1999-2016
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