Sign in to follow this  
Followers 0
dantay9

GMail Email Checker

53 posts in this topic

#1 ·  Posted (edited)

This is a way to connect to GMail's atom feed and extract information from it. All you need to do is enter a valid username and password in the corresponding global variables. GMail's atom feed only shows the unread email, but it is a heck of a lot easier to use this than it would be to implement ssl and pop3 to get the full e-mail.

Anyway, I split the main part of the script that dealt with GMail into another file and left the example in the main file. Feel free to improve on my simple example.

This is much lighter on the CPU than GMail Notifier and doesn't have all the eyecandy that sucks up cpu. But that doesn't mean I didn't spend a good chunk of time trying to get my gui to look good!

Big thanks to psynegy for getting me started on this.

Zipped Images and Source Available here.

I uploaded what I could find here. Not sure if it works or not.

Edited by dantay9

[font="Verdana"] [size="2"]"[/size][/font]Failure is not an option -- it comes packaged with Windows"[font="Verdana"][size="2"] Gecko Web Browser[/size][/font][font="Verdana"][size="2"], [/size][/font][font="Verdana"][size="2"]Yahtzee![/size][/font][font="Verdana"][size="2"], Toolbar Launcher (like RocketDock)[/size][/font][font="Verdana"][size="2"]Internet Blocker, Simple Calculator, Local Weather, Easy GDI+ GUI [/size][/font][font="Verdana"][size="2"]Triangle Solver, TCP File Transfer, [/size][/font][font="Verdana"][size="2"]Valuater's Autoit Wrappers[/size][/font][font="Verdana"][size="3"][size="2"][size="2"]OOP In AutoIt[/size][/size][/size][/font][font="Verdana"][size="2"][size="1"]Using Windows XP SP3, 1GB RAM, AMD Athlon Processor @ 2.1 GHzCheck me out at gadgets.freehostrocket.com[/size][/size][/font]

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

---

Edited by playlet

Share this post


Link to post
Share on other sites

Thanks playlet. Glad you like it.


[font="Verdana"] [size="2"]"[/size][/font]Failure is not an option -- it comes packaged with Windows"[font="Verdana"][size="2"] Gecko Web Browser[/size][/font][font="Verdana"][size="2"], [/size][/font][font="Verdana"][size="2"]Yahtzee![/size][/font][font="Verdana"][size="2"], Toolbar Launcher (like RocketDock)[/size][/font][font="Verdana"][size="2"]Internet Blocker, Simple Calculator, Local Weather, Easy GDI+ GUI [/size][/font][font="Verdana"][size="2"]Triangle Solver, TCP File Transfer, [/size][/font][font="Verdana"][size="2"]Valuater's Autoit Wrappers[/size][/font][font="Verdana"][size="3"][size="2"][size="2"]OOP In AutoIt[/size][/size][/size][/font][font="Verdana"][size="2"][size="1"]Using Windows XP SP3, 1GB RAM, AMD Athlon Processor @ 2.1 GHzCheck me out at gadgets.freehostrocket.com[/size][/size][/font]

Share this post


Link to post
Share on other sites

I'm not sure exactly why your account isn't working. I made a brand new account and it worked fine.

Make sure you are using just the username not username@gmail.com as your username.

If you still can't get it to work, the test account that worked for me has a username of "mailtest116" and a password of "mypassword". Try that and see if that works.


[font="Verdana"] [size="2"]"[/size][/font]Failure is not an option -- it comes packaged with Windows"[font="Verdana"][size="2"] Gecko Web Browser[/size][/font][font="Verdana"][size="2"], [/size][/font][font="Verdana"][size="2"]Yahtzee![/size][/font][font="Verdana"][size="2"], Toolbar Launcher (like RocketDock)[/size][/font][font="Verdana"][size="2"]Internet Blocker, Simple Calculator, Local Weather, Easy GDI+ GUI [/size][/font][font="Verdana"][size="2"]Triangle Solver, TCP File Transfer, [/size][/font][font="Verdana"][size="2"]Valuater's Autoit Wrappers[/size][/font][font="Verdana"][size="3"][size="2"][size="2"]OOP In AutoIt[/size][/size][/size][/font][font="Verdana"][size="2"][size="1"]Using Windows XP SP3, 1GB RAM, AMD Athlon Processor @ 2.1 GHzCheck me out at gadgets.freehostrocket.com[/size][/size][/font]

Share this post


Link to post
Share on other sites

Just checked out your script been trying to get it to work with google apps with hosted domains so I changed the atom feed, it comes up theres no new messages just shows the tab anything else I would need to change to make it work ?

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Just checked out your script been trying to get it to work with google apps with hosted domains so I changed the atom feed, it comes up theres no new messages just shows the tab anything else I would need to change to make it work ?

This is the main part of the code that allows you to login to the feeds.

$oHTTP = ObjCreate("winhttp.winhttprequest.5.1") ;create a http request object
$oHTTP.Open("GET", "https://gmail.google.com/gmail/feed/atom", False) ;get data from the feed
$oHTTP.SetCredentials($Username, $Password, 0) ;set the credentials
$oHTTP.Send() ;send the data
Return $oHTTP.ResponseText ;get the response

I haven't personally tried it with any other feeds, but I would guess you have to change the address to another feed and then parse the returned xml just like I have in my GMail code.

Edited by dantay9

[font="Verdana"] [size="2"]"[/size][/font]Failure is not an option -- it comes packaged with Windows"[font="Verdana"][size="2"] Gecko Web Browser[/size][/font][font="Verdana"][size="2"], [/size][/font][font="Verdana"][size="2"]Yahtzee![/size][/font][font="Verdana"][size="2"], Toolbar Launcher (like RocketDock)[/size][/font][font="Verdana"][size="2"]Internet Blocker, Simple Calculator, Local Weather, Easy GDI+ GUI [/size][/font][font="Verdana"][size="2"]Triangle Solver, TCP File Transfer, [/size][/font][font="Verdana"][size="2"]Valuater's Autoit Wrappers[/size][/font][font="Verdana"][size="3"][size="2"][size="2"]OOP In AutoIt[/size][/size][/size][/font][font="Verdana"][size="2"][size="1"]Using Windows XP SP3, 1GB RAM, AMD Athlon Processor @ 2.1 GHzCheck me out at gadgets.freehostrocket.com[/size][/size][/font]

Share this post


Link to post
Share on other sites

ok I tried that and got a result, except for it seems like the notification is delayed? all it's doing is pointing to a different feed then so I can't understand why it's lagging ?

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

This program was made specifically for GMail, so I don't know exactly what else parts of the code can be tweaked to do. If you have questions, post a topic in the General Help forum and you will get much better help from people who know a lot more than I do.

Edited by dantay9

[font="Verdana"] [size="2"]"[/size][/font]Failure is not an option -- it comes packaged with Windows"[font="Verdana"][size="2"] Gecko Web Browser[/size][/font][font="Verdana"][size="2"], [/size][/font][font="Verdana"][size="2"]Yahtzee![/size][/font][font="Verdana"][size="2"], Toolbar Launcher (like RocketDock)[/size][/font][font="Verdana"][size="2"]Internet Blocker, Simple Calculator, Local Weather, Easy GDI+ GUI [/size][/font][font="Verdana"][size="2"]Triangle Solver, TCP File Transfer, [/size][/font][font="Verdana"][size="2"]Valuater's Autoit Wrappers[/size][/font][font="Verdana"][size="3"][size="2"][size="2"]OOP In AutoIt[/size][/size][/size][/font][font="Verdana"][size="2"][size="1"]Using Windows XP SP3, 1GB RAM, AMD Athlon Processor @ 2.1 GHzCheck me out at gadgets.freehostrocket.com[/size][/size][/font]

Share this post


Link to post
Share on other sites

Ok just one question regarding your script is there a way I can make it more regularly checking ?

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Of course you can check it manually by right clicking on the tray icon and selecting "Check Unread Mail".

You can do this automatically by using AdlibRegister("AutoUpdateGMail", time in milliseconds) and a new function to wrap the two important functions together:

Func AutoUpdateGMail()
    UpdateGMail()
    ShowGUI()
EndFunc
Edited by dantay9

[font="Verdana"] [size="2"]"[/size][/font]Failure is not an option -- it comes packaged with Windows"[font="Verdana"][size="2"] Gecko Web Browser[/size][/font][font="Verdana"][size="2"], [/size][/font][font="Verdana"][size="2"]Yahtzee![/size][/font][font="Verdana"][size="2"], Toolbar Launcher (like RocketDock)[/size][/font][font="Verdana"][size="2"]Internet Blocker, Simple Calculator, Local Weather, Easy GDI+ GUI [/size][/font][font="Verdana"][size="2"]Triangle Solver, TCP File Transfer, [/size][/font][font="Verdana"][size="2"]Valuater's Autoit Wrappers[/size][/font][font="Verdana"][size="3"][size="2"][size="2"]OOP In AutoIt[/size][/size][/size][/font][font="Verdana"][size="2"][size="1"]Using Windows XP SP3, 1GB RAM, AMD Athlon Processor @ 2.1 GHzCheck me out at gadgets.freehostrocket.com[/size][/size][/font]

Share this post


Link to post
Share on other sites

Hi Dantay9

That is very slick...and well written. I've wanted to do something like this for a long time but wasn't quite sure how to begin. Thanks for this example, I'm going to have to study it.

Picea892

Share this post


Link to post
Share on other sites

Hi Dantay9,

Very nice script!

It works on XP SP3, however in Windows 7 it always returns "the credentials provided are not valid" error.

Any idea why it does not work on W7?

Thx a lot,

Luca

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

Sorry for the delay, my computer was acting up and had to recover it. Thanks for the comment, but I don't have access to Windows 7 and am not very familiar with it so I can't really help you much. You will have to debug it yourself.

Edited by dantay9

[font="Verdana"] [size="2"]"[/size][/font]Failure is not an option -- it comes packaged with Windows"[font="Verdana"][size="2"] Gecko Web Browser[/size][/font][font="Verdana"][size="2"], [/size][/font][font="Verdana"][size="2"]Yahtzee![/size][/font][font="Verdana"][size="2"], Toolbar Launcher (like RocketDock)[/size][/font][font="Verdana"][size="2"]Internet Blocker, Simple Calculator, Local Weather, Easy GDI+ GUI [/size][/font][font="Verdana"][size="2"]Triangle Solver, TCP File Transfer, [/size][/font][font="Verdana"][size="2"]Valuater's Autoit Wrappers[/size][/font][font="Verdana"][size="3"][size="2"][size="2"]OOP In AutoIt[/size][/size][/size][/font][font="Verdana"][size="2"][size="1"]Using Windows XP SP3, 1GB RAM, AMD Athlon Processor @ 2.1 GHzCheck me out at gadgets.freehostrocket.com[/size][/size][/font]

Share this post


Link to post
Share on other sites
nice job and thanks for sharing with us... but your gui should be better

0x5748415420444F20594F552057414E543F

Share this post


Link to post
Share on other sites

#16 ·  Posted

Thanks. I wasn't planning on spending a lot of time on it. I was just making a little example. Then I decided that I could use a little practice with GDI+ so I incorporated that into the example.


[font="Verdana"] [size="2"]"[/size][/font]Failure is not an option -- it comes packaged with Windows"[font="Verdana"][size="2"] Gecko Web Browser[/size][/font][font="Verdana"][size="2"], [/size][/font][font="Verdana"][size="2"]Yahtzee![/size][/font][font="Verdana"][size="2"], Toolbar Launcher (like RocketDock)[/size][/font][font="Verdana"][size="2"]Internet Blocker, Simple Calculator, Local Weather, Easy GDI+ GUI [/size][/font][font="Verdana"][size="2"]Triangle Solver, TCP File Transfer, [/size][/font][font="Verdana"][size="2"]Valuater's Autoit Wrappers[/size][/font][font="Verdana"][size="3"][size="2"][size="2"]OOP In AutoIt[/size][/size][/size][/font][font="Verdana"][size="2"][size="1"]Using Windows XP SP3, 1GB RAM, AMD Athlon Processor @ 2.1 GHzCheck me out at gadgets.freehostrocket.com[/size][/size][/font]

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

In Windows 7 the WinHTTP stuff doesn't work exactly right, there are complaints all over the net for various languages. However, I have found a way to make it work with minor modifications...

Breakdown:

I used the INet UDF rather than the WinHTTP COM interface. It's fairly slow, of course I have no way to compare the other way.

Func UpdateGmailXML($Username, $Password)
    ;$oHTTP = ObjCreate("winhttp.winhttprequest.5.1")
    ;$oHTTP.Open("GET", "https://" & $Username & ":" & $Password & "@" & "gmail.google.com/gmail/feed/atom", False)
    ;$oHTTP.SetCredentials($Username, $Password, 0)
    ;$oHTTP.Send()
    $Response = _INetGetSource("https://" & $Username & ":" & $Password & "@" & "gmail.google.com/gmail/feed/atom")
    ;Local $Response = $oHTTP.ResponseText
    If StringLeft(StringStripWS($Response, 8), 46) = "<HTML><HEAD><TITLE>Unauthorized</TITLE></HEAD>" Then
        $Authorized = False
        Return SetError(1, 0, 0)
    Else
        $Authorized = True
    EndIf

    $GMailXML = $Response ;set global variable
    $aEmailXML = _StringBetween($GMailXML, "<entry>", "</entry>") ;set global variable
    If Not IsArray($aEmailXML) Then
        $NoEmail = True
        Return SetError(2, 0, 0)
    Else
        $NoEmail = False
    EndIf

    ReDim $aEmailTitles[UBound($aEmailXML)]
    ReDim $aEmailSummaries[UBound($aEmailXML)]
    ReDim $aEmailTimes[UBound($aEmailXML)]
    ReDim $aEmailDates[UBound($aEmailXML)]
    ReDim $aEmailFromNames[UBound($aEmailXML)]
    ReDim $aEmailFromEmails[UBound($aEmailXML)]
    For $i = 0 To UBound($aEmailXML) - 1
        $aEmailTitles[$i] = sStringBetween($aEmailXML[$i], "<title>", "</title>")
        If $aEmailTitles[$i] = "" Then $aEmailTitles[$i] = "(no subject)"

        $aEmailSummaries[$i] = sStringBetween($aEmailXML[$i], "<summary>", "</summary>")

        Local $TimeDate = sStringBetween($aEmailXML[$i], "<issued>", "</issued>")
        $aEmailDates[$i] = DateFromTimeDate($TimeDate)
        $aEmailTimes[$i] = TimeFromTimeDate($TimeDate)

        $aEmailFromNames[$i] = sStringBetween($aEmailXML[$i], "<name>", "</name>")

        $aEmailFromEmails[$i] = sStringBetween($aEmailXML[$i], "<email>", "</email>")
    Next
EndFunc ;==>UpdateGmailXML

As you can see, I only modified a few lines.

;$oHTTP = ObjCreate("winhttp.winhttprequest.5.1")

;$oHTTP.Open("GET", "https://" & $Username & ":" & $Password & "@" & "gmail.google.com/gmail/feed/atom", False)

;$oHTTP.SetCredentials($Username, $Password, 0)

;$oHTTP.Send()

$Response = _INetGetSource("https://" & $Username & ":" & $Password & "@" & "gmail.google.com/gmail/feed/atom")

;Local $Response = $oHTTP.ResponseText

Edited by BinaryBrother

Share this post


Link to post
Share on other sites

#18 ·  Posted (edited)

Actually, there isn't a whole lot of difference. It is only about 500ms slower on my machine, definately tolerable. Thanks. Updated!

Edited by dantay9

[font="Verdana"] [size="2"]"[/size][/font]Failure is not an option -- it comes packaged with Windows"[font="Verdana"][size="2"] Gecko Web Browser[/size][/font][font="Verdana"][size="2"], [/size][/font][font="Verdana"][size="2"]Yahtzee![/size][/font][font="Verdana"][size="2"], Toolbar Launcher (like RocketDock)[/size][/font][font="Verdana"][size="2"]Internet Blocker, Simple Calculator, Local Weather, Easy GDI+ GUI [/size][/font][font="Verdana"][size="2"]Triangle Solver, TCP File Transfer, [/size][/font][font="Verdana"][size="2"]Valuater's Autoit Wrappers[/size][/font][font="Verdana"][size="3"][size="2"][size="2"]OOP In AutoIt[/size][/size][/size][/font][font="Verdana"][size="2"][size="1"]Using Windows XP SP3, 1GB RAM, AMD Athlon Processor @ 2.1 GHzCheck me out at gadgets.freehostrocket.com[/size][/size][/font]

Share this post


Link to post
Share on other sites

#19 ·  Posted

I'm assuming Vista will have the same issue. If so you'll want to verify against 7 and Vista. I actually started molding your Gmail.au3 (UDF style) to what I needed and ended up just using the INet UDF and StringBetween. Your code is quite a bit more complicated than it needs to be IMO, but it gets the job done. Thanks, keep up the coding! :idea:

Share this post


Link to post
Share on other sites

#20 ·  Posted

Yeah, it is way too complex. Normally, when I finish a project, I go back and recode it, copying most of the code from the previous version. This removes most of the unneeded code. I just never did that with this project.


[font="Verdana"] [size="2"]"[/size][/font]Failure is not an option -- it comes packaged with Windows"[font="Verdana"][size="2"] Gecko Web Browser[/size][/font][font="Verdana"][size="2"], [/size][/font][font="Verdana"][size="2"]Yahtzee![/size][/font][font="Verdana"][size="2"], Toolbar Launcher (like RocketDock)[/size][/font][font="Verdana"][size="2"]Internet Blocker, Simple Calculator, Local Weather, Easy GDI+ GUI [/size][/font][font="Verdana"][size="2"]Triangle Solver, TCP File Transfer, [/size][/font][font="Verdana"][size="2"]Valuater's Autoit Wrappers[/size][/font][font="Verdana"][size="3"][size="2"][size="2"]OOP In AutoIt[/size][/size][/size][/font][font="Verdana"][size="2"][size="1"]Using Windows XP SP3, 1GB RAM, AMD Athlon Processor @ 2.1 GHzCheck me out at gadgets.freehostrocket.com[/size][/size][/font]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0