Global $eReturn
Global $Emails = @extended
Global $Count, $NumberofEmails = 0
Global $User = InputBox("Gmail", "Please enter user name.")
Global $Pass = InputBox("Gmail", "Please enter password.", "", "*")
_Display()
_Notify_RegMsg()
_Notify_Locate(0)
AdlibRegister("_Display", 5000)
_Notify_Set(Default)
While 1
Sleep(10)
If $NumberofEmails < $Count Then
For $x = $NumberofEmails To $Count
_Notify_Show(@AutoItExe, "", $eReturn[$x][1] & @CR & $eReturn[$x][0])
Next
$NumberofEmails = $Count
ElseIf $NumberofEmails > $Count Then
$NumberofEmails = $Count
EndIf
WEnd
Func _Display()
$eReturn = _CheckMail($User, $Pass)
Switch @error
Case 1
MsgBox(0,"Error!","Couldn't get your new emails for some reason...")
Exit
Case 2,3
MsgBox(0,"Error!","you need to enter an user name and password!")
Exit
Case 4
MsgBox(16,"Error!","Error Getting URL Source!")
Exit
Case 5
MsgBox(16,"Error!","No response?")
Exit
Case 6
MsgBox(16,"Error!","Unauthorized access, possibly a wrong username or password!")
Exit
EndSwitch
EndFunc
Func _CheckMail($UserName, $Pswd, $UserAgentString = "")
If Not $UserName Then Return SetError(2,0,0)
If Not $Pswd Then Return SetError(3,0,0)
If $UserAgentString Then HttpSetUserAgent($UserAgentString)
Local $source = InetRead("https://" & $UserName & ":" & $Pswd & "@gmail.google.com/gmail/feed/atom",1)
If @error Then
ConsoleWrite("!>Error Getting URL Source!" & @CR & " 404>@Error =" & @error & @CR & " 404>@Extended =" & @extended & @CR)
Return SetError(4,0,0)
EndIf
If $source Then
$source = BinaryToString($source)
MsgBox (0,"Source", $source)
Else
Return SetError(5,0,0)
EndIf
MsgBox (0,"A","RadheRadhe")
If StringLeft(StringStripWS($source, 8), 46) == "
Unauthorized" Then Return SetError(6, 0, 0)
MsgBox (0,"A","1")
;If Not Number(StringBetween($source, "", "")) Then Return SetError(0,0,0)
MsgBox (0,"A","2")
Local $EmailCount = StringBetween($source, "", "")
MsgBox (0,"A","3")
Local $Email = _StringBetween($source, "", "")
If @error Then Return SetError(1, 0, 0)
Local $Time
Local $Datum[$EmailCount][6]
MsgBox (0,"A","4")
$Datum[0][0] = StringBetween($source, "", "")
$Datum[0][1] = StringBetween($source, "", "")
MsgBox (0,"A","5")
For $i = 0 To $EmailCount - 1
$Datum[$i][0] = StringBetween($Email[$i], "", "")
If Not $Datum[$i][0] Then $Datum[$i][0] = "(no subject)"
$Datum[$i][1] = StringBetween($Email[$i], "", "")
$Datum[$i][2] = StringBetween($Email[$i], "", "")
$Datum[$i][3] = StringBetween($Email[$i], "", "")
$Time = StringBetween($Email[$i], "", "")
$Datum[$i][4] = DateFromTimeDate($Time)
$Datum[$i][5] = TimeFromTimeDate($Time)
Next
MsgBox (0,"A","6")
Return SetError(0,$EmailCount,$Datum)
EndFunc
MsgBox (0,"A","RadheRadhe1")
Func StringBetween($Str, $S, $E)
MsgBox (0,"Value", $S)
MsgBox (0,"Value", $E)
Local $B =_StringBetween($Str, $S, $E)
MsgBox (0,"Value", $B)
If @error Then Return SetError(1,0,0)
Return SetError(0,0,$B[0])
EndFunc ;==>StringBetween
Func DateFromTimeDate($String)
Local $RegEx = StringRegExp($String, "(?d{2}|d{4})(?:-)(?d{1,2})(?:-)(?d{1,2})", 1)
If IsArray($RegEx) Then
Return Int($RegEx[0]) & "/" & Int($RegEx[1]) & "/" & Int($RegEx[2])
Else
Return SetError(1, 0, 0)
EndIf
EndFunc ;==>DateFromTimeDate
Func TimeFromTimeDate($String)
Local $RegEx = StringRegExp($String, "(?d{1,2})(?::)(?d{1,2})(?::)(?d{1,2})", 1)
If IsArray($RegEx) Then
Return (Int($RegEx[0]) - 4) & ":" & Int($RegEx[1]) & ":" & Int($RegEx[2]) ;don't know why I have to subtract 4
Else
Return SetError(1, 0, 0)
EndIf
EndFunc ;==>TimeFromTimeDate