954,515 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?

Simple Gmail Client in vb.net

By sandeepparekh9 on Dec 17th, 2010 4:17 pm

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 forSend 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 ..

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

Vineeth K
Posting Whiz in Training
206 posts since Sep 2009
Reputation Points: 20
Solved Threads: 18
 

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

kothaisaravan
Junior Poster in Training
51 posts since Oct 2011
Reputation Points: 10
Solved Threads: 2
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You