Simple Gmail Client in vb.net

sandeepparekh9

hi.. guys.. just joined daniweb.. and this is my first post

this one's very easy... i suffered a lot to find this simple program.. i hope you guys like it..

here is a quick preview of it...http://lh4.ggpht.com/_blnOia1d0Pw/TQs3BhaCClI/AAAAAAAACco/3vPqJIlyG-M/gmail%20client.JPG

1. First Of All Add the Following Line to your code:

Imports System.Net.Mail

2. Now As Show in the image create the basic layout of the application.

3. Enter you Gmail's user id and pass in the required filed

4. the TO,Subject,Body text box are easily explainable...

5. define the following's

Dim msg As New MailMessage
    Dim i As Integer

6. Now is the Main coding for Send Button.. here it is

msg.To.Add(Me.txtto.Text)
        msg.From = New MailAddress(Me.txtuser.Text)
        msg.Subject = Me.txtsubject.Text
        msg.Body = Me.txtbody.Text
        'msg.Attachments.Add(New Attachment(Me.txtattach.Text))
        '' for attachment

        For i = 0 To Me.ListBox1.Items.Count - 1
            msg.Attachments.Add(New Attachment(Me.ListBox1.Items(i).ToString))
        Next


        Dim smtp As New SmtpClient
        smtp.Host = "smtp.gmail.com"
        smtp.EnableSsl = True
        smtp.Port = 587
        smtp.Credentials = New Net.NetworkCredential(Me.txtuser.Text, Me.txtpass.Text)
        smtp.Send(msg)

7. Let's see the coding for the attachment button...

Dim d As New OpenFileDialog
        d.ShowDialog()
        Me.ListBox1.Items.Add(d.FileName.ToString())
        Me.ListBox1.Visible = True

8. well its done ... easy ..

414 Views
About the Author
Vineeth K 10 Posting Whiz in Training

thanks man, this one is really simple one i really liked it ...

kothaisaravan 0 Light Poster

Hi I got error message with this code "Failure Sending Mail" with SMTP Excxeption.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.