dantay9 Posted March 20, 2010 Share Posted March 20, 2010 (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 May 5, 2012 by dantay9 Link to comment Share on other sites More sharing options...
playlet Posted March 20, 2010 Share Posted March 20, 2010 (edited) --- Edited August 18, 2016 by playlet Link to comment Share on other sites More sharing options...
dantay9 Posted March 20, 2010 Author Share Posted March 20, 2010 Thanks playlet. Glad you like it. Link to comment Share on other sites More sharing options...
James Posted March 20, 2010 Share Posted March 20, 2010 Seems like some very nice code, but when I entered my username and password into the script, it kept telling me they were wrong? Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
dantay9 Posted March 20, 2010 Author Share Posted March 20, 2010 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. Link to comment Share on other sites More sharing options...
pikerslayer Posted March 21, 2010 Share Posted March 21, 2010 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 ? Link to comment Share on other sites More sharing options...
dantay9 Posted March 21, 2010 Author Share Posted March 21, 2010 (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 March 21, 2010 by dantay9 Link to comment Share on other sites More sharing options...
pikerslayer Posted March 21, 2010 Share Posted March 21, 2010 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 ? Link to comment Share on other sites More sharing options...
dantay9 Posted March 21, 2010 Author Share Posted March 21, 2010 (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 March 21, 2010 by dantay9 Link to comment Share on other sites More sharing options...
pikerslayer Posted March 21, 2010 Share Posted March 21, 2010 Ok just one question regarding your script is there a way I can make it more regularly checking ? Link to comment Share on other sites More sharing options...
dantay9 Posted March 22, 2010 Author Share Posted March 22, 2010 (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 March 22, 2010 by dantay9 Link to comment Share on other sites More sharing options...
picea892 Posted March 24, 2010 Share Posted March 24, 2010 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 Link to comment Share on other sites More sharing options...
Luca71 Posted April 25, 2010 Share Posted April 25, 2010 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 Link to comment Share on other sites More sharing options...
dantay9 Posted April 29, 2010 Author Share Posted April 29, 2010 (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 April 29, 2010 by dantay9 Link to comment Share on other sites More sharing options...
semedboy Posted April 30, 2010 Share Posted April 30, 2010 nice job and thanks for sharing with us... but your gui should be better 0x5748415420444F20594F552057414E543F Link to comment Share on other sites More sharing options...
dantay9 Posted May 2, 2010 Author Share Posted May 2, 2010 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. Link to comment Share on other sites More sharing options...
BinaryBrother Posted May 2, 2010 Share Posted May 2, 2010 (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.expandcollapse popupFunc 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 ;==>UpdateGmailXMLAs 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 May 2, 2010 by BinaryBrother SIGNATURE_0X800007D NOT FOUND Link to comment Share on other sites More sharing options...
dantay9 Posted May 3, 2010 Author Share Posted May 3, 2010 (edited) Actually, there isn't a whole lot of difference. It is only about 500ms slower on my machine, definately tolerable. Thanks. Updated! Edited May 3, 2010 by dantay9 Link to comment Share on other sites More sharing options...
BinaryBrother Posted May 3, 2010 Share Posted May 3, 2010 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! SIGNATURE_0X800007D NOT FOUND Link to comment Share on other sites More sharing options...
dantay9 Posted May 3, 2010 Author Share Posted May 3, 2010 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. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now