Click here to Skip to main content
12,507,058 members (62,538 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as

Stats

9.8K views
823 downloads
10 bookmarked
Posted

How to Make Your Own Gmail Notifier Using VB.NET

, 11 Jan 2014 CPOL
Rate this:
Please Sign up or sign in to vote.
This tip shows you how to make your own Gmail Notiifer using VB.NET

Introduction

If you want to make your own Gmail Notifier, you are at the right place. Google does not have an official Gmail API. So, you have to exploit the Feed facility of Gmail to build our Gmail Notifier.

Background

Gmail Feed is a useful feature provided by Gmail using which we can subscribe to emails using a Feed Reader supporting authentification.

Using the Code

We first create a new instance of WebClient class and then request feed from Gmail Using the Username and the Password as the networks parameters. So, we must exploit the Gmail Feed which is an ATOM feed. We have to parse the response as an XML file using the XmlDocument as shown in the following code:

Imports System.Xml
Imports System.Text
Public Class LoginForm1
    Private Sub OK_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles OK.Click
        Dim objClient As New System.Net.WebClient
        Dim nodelist As XmlNodeList
        Dim node As XmlNode
        Dim response As String
        Dim xmlDoc As New XmlDocument
        Try

            objClient.Credentials = New System.Net.NetworkCredential_
            (UsernameTextBox.Text.Trim, PasswordTextBox.Text.Trim)
            response = Encoding.UTF8.GetString(objClient.DownloadData_
            ("https://mail.google.com/mail/feed/atom"))
            response = response.Replace("<feed version=""0.3"" 
            xmlns=""http://purl.org/atom/ns#"">", "<feed>")

            xmlDoc.LoadXml(response)
            node = xmlDoc.SelectSingleNode("/feed/fullcount")
            mailCount = node.InnerText 'Get the number of unread emails

            If mailCount > 0 Then
                ReDim emailFrom(mailCount - 1)
                ReDim emailMessages(mailCount - 1)
                nodelist = xmlDoc.SelectNodes("/feed/entry")
                node = xmlDoc.SelectSingleNode("title")

                For Each node In nodelist
                    emailMessages(tempCounter) = node.ChildNodes.Item(0).InnerText
                    emailFrom(tempCounter) = node.ChildNodes.Item(6).ChildNodes(0).InnerText
                    tempCounter += 1
                Next
                tempCounter = 0
            End If
            Me.Hide()
            Form1.Show()
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub
End Class

This is the important part of our application. So now, you need to download the source code and try to compile it.

Any comments are welcome.

License

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

Share

About the Author

Hadrich Mohamed
Student
Tunisia Tunisia
Microsoft Certified Professional, Big Data and Cloud Architect.
Mail : hadrichmed@gmail.com

You may also be interested in...

Pro
Pro

Comments and Discussions

 
Questionnice job Pin
Member 1262025916-Aug-16 17:05
memberMember 1262025916-Aug-16 17:05 
Questionwork one time only Pin
Member 1019500419-Mar-14 0:09
memberMember 1019500419-Mar-14 0:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160927.1 | Last Updated 12 Jan 2014
Article Copyright 2014 by Hadrich Mohamed
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid