Jump to content

Recommended Posts

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
  • Replies 52
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted

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.

Posted

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 ?

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
Posted

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 ?

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
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
Posted

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

  • 1 month later...
Posted

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

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

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

SIGNATURE_0X800007D NOT FOUND

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
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:

SIGNATURE_0X800007D NOT FOUND

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.

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...