Jump to content

GMail Email Checker


dantay9
 Share

Recommended Posts

  • Replies 52
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

I had to add ...

#include <INet.au3>

... to the code. Now, however, it fails saying "the credentials provided are not valid" every time.

Do you have to enable something on your Gmail account for this to work?

I'm really looking for a way to get this to work or maybe find a Google Buzz UDF.

EDIT: Figured it out, had to make the following change:

-------------------------------------------------------------------

If @OSVersion = "WIN_7" Then
to
If @OSVersion = "WIN_7" OR @OSVersion = "WIN_VISTA" Then

EDIT2: Nope, that didn't work either.

Edited by Yorn
Link to comment
Share on other sites

This is a wonderfull UDF.

I looked for that from a long time.

This run very well for me.

How can i to read all mails if i want and not just the unread mails .

Thanks for all help ?

That's not possible at this time. After all, I don't think the purpose of that feed is to list ALL emails, only new ones. You'll have to utilize another method. :/

SIGNATURE_0X800007D NOT FOUND

Link to comment
Share on other sites

I had to add ...

#include <INet.au3>

... to the code. Now, however, it fails saying "the credentials provided are not valid" every time.

Do you have to enable something on your Gmail account for this to work?

I'm really looking for a way to get this to work or maybe find a Google Buzz UDF.

EDIT: Figured it out, had to make the following change:

-------------------------------------------------------------------

If @OSVersion = "WIN_7" Then
to
If @OSVersion = "WIN_7" OR @OSVersion = "WIN_VISTA" Then

EDIT2: Nope, that didn't work either.

You must to keep for Vista :

If @OSVersion = "WIN_7" Then

and not :

If @OSVersion = "WIN_7" OR @OSVersion = "WIN_VISTA" Then

who don't run for me !

Edited by pierrotm777
Link to comment
Share on other sites

@pierrotm777

I don't think that is what the feed was designed for. It is mainly for just notifying you that you have a message. Then you check the message yourself. This isn't as feature rich as GMail Notifier. I was planning on just making a simple example, but I got carried away with the GUI and ended up making a useful head start to a fully featured script.

Edited by dantay9
Link to comment
Share on other sites

Here's the code of what I got working in case it helps anyone wanting to expand on this method. I made a sort of "service-like" program that triggers messages to show as tray tips as they come in. This was primarily intended to be a program that lets me remotely reboot computers on our network just by using a cell phone to text/email a specific address. It worked really well, in fact, but I'm not sure if it will work on Windows 7 or XP. I have 32-bit Vista.

Just load up your own Gmail $Username and $Password and text/email it with "@gmail.com" to test after running.

#include <Array.au3>
#include <String.au3>
#include <file.au3>
#include <INet.au3>
Global $Username = ""
Global $Password = ""
Global $entry, $Count, $PreviousCount
Global $oMyRet[2]
Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc")

$Response = _INetGetSource("https://" & $Username & ":" & $Password & "@" & "gmail.google.com/gmail/feed/atom")
$PreviousCount = _StringBetween($Response,"<fullcount>","</fullcount>")

While 1
    $Response = _INetGetSource("https://" & $Username & ":" & $Password & "@" & "gmail.google.com/gmail/feed/atom")
    $Count = _StringBetween($Response,"<fullcount>","</fullcount>")
    If $Count[0] > $PreviousCount[0] Then
        $Response = _INetGetSource("https://" & $Username & ":" & $Password & "@" & "gmail.google.com/gmail/feed/atom")
        $Array = _StringBetween($Response,"<entry>","</entry>")
        _ArrayReverse($Array)
        $entry = _ArrayPop($Array)
        $Summary = _StringBetween($entry,"<summary>","</summary>")
        $Sender = _StringBetween($entry,"<email>","</email>")
        TrayTip($Sender[0],$Summary[0], 10, 16)
        _SendEmail($Sender[0],"Message recieved!")
        ;Run("shutdown /r /m \\" & $Summary[0])
        $PreviousCount[0] = $Count[0]
        Sleep(5000)
    Elseif $Count[0] < $PreviousCount[0] Then
        $PreviousCount[0] = $Count[0]
        TrayTip("Count", "Changed to " & $PreviousCount[0], 10, 16)
        Sleep(5000)
    EndIf
    Sleep(15000)
    TrayTip("Count", "No Change from " & $Count[0], 10, 16)
    Sleep(10000)
WEnd

Func _SendEmail($inc_ToAddress,$inc_Body)
    $SmtpServer = "smtp.gmail.com"          ; address for the smtp-server to use - REQUIRED
    $FromName = $Username                   ; name from who the email was sent
    $FromAddress = $Username & "@gmail.com" ; address from where the mail should come
    $ToAddress = $inc_ToAddress             ; destination address of the email - REQUIRED
    $Subject = ""                           ; subject from the email - can be anything you want it to be
    $Body = $inc_Body                       ; the messagebody from the mail - can be left blank but then you get a blank mail
    $AttachFiles = ""                       ; the file(s) you want to attach seperated with a ; (Semicolon) - leave blank if not needed
    $CcAddress = ""                         ; address for cc - leave blank if not needed
    $BccAddress = ""                        ; address for bcc - leave blank if not needed
    $Importance = "Normal"                  ; Send message priority: "High", "Normal", "Low"
    ;Two entries are defined above as Globals
    ;$Username = "******"                   ; username for the account used from where the mail gets sent - REQUIRED
    ;$Password = "********"                 ; password for the account used from where the mail gets sent - REQUIRED
    ;We are using GMAIL so the following have to be commented out
    ;$IPPort = 25                           ; port used for sending the mail
    ;$ssl = 0                               ; enables/disables secure socket layer sending - put to 1 if using httpS
    ;And these need uncommented
    $IPPort=465                             ; GMAIL port used for sending the mail
    $ssl=1                                  ; GMAILenables/disables secure socket layer sending - put to 1 if using httpS

    Return _INetSmtpMailCom($SmtpServer, $FromName, $FromAddress, $ToAddress, $Subject, $Body, $AttachFiles, $CcAddress, $BccAddress, $Importance, $Username, $Password, $IPPort, $ssl)

EndFunc

Func _INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject = "", $as_Body = "", $s_AttachFiles = "", $s_CcAddress = "", $s_BccAddress = "", $s_Importance="Normal", $s_Username = "", $s_Password = "", $IPPort = 25, $ssl = 0)
    Local $objEmail = ObjCreate("CDO.Message")
    $objEmail.From = '"' & $s_FromName & '" <' & $s_FromAddress & '>'
    $objEmail.To = $s_ToAddress
    Local $i_Error = 0
    Local $i_Error_desciption = ""
    If $s_CcAddress <> "" Then $objEmail.Cc = $s_CcAddress
    If $s_BccAddress <> "" Then $objEmail.Bcc = $s_BccAddress
    $objEmail.Subject = $s_Subject
    If StringInStr($as_Body, "<") And StringInStr($as_Body, ">") Then
        $objEmail.HTMLBody = $as_Body
    Else
        $objEmail.Textbody = $as_Body & @CRLF
    EndIf
    If $s_AttachFiles <> "" Then
        Local $S_Files2Attach = StringSplit($s_AttachFiles, ";")
        For $x = 1 To $S_Files2Attach[0]
            $S_Files2Attach[$x] = _PathFull($S_Files2Attach[$x])
            ConsoleWrite('@@ Debug(62) : $S_Files2Attach = ' & $S_Files2Attach & @LF & '>Error code: ' & @error & @LF) ;### Debug Console
            If FileExists($S_Files2Attach[$x]) Then
                $objEmail.AddAttachment ($S_Files2Attach[$x])
            Else
                ConsoleWrite('!> File not found to attach: ' & $S_Files2Attach[$x] & @LF)
                SetError(1)
                Return 0
            EndIf
        Next
    EndIf
    $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = $s_SmtpServer
    If Number($IPPort) = 0 then $IPPort = 25
    $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = $IPPort
    ;Authenticated SMTP
    If $s_Username <> "" Then
        $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
        $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = $s_Username
        $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = $s_Password
    EndIf
    If $ssl Then
        $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
    EndIf
    ;Update settings
    $objEmail.Configuration.Fields.Update
    ; Set Email Importance
    Switch $s_Importance
        Case "High"
            $objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "High"
        Case "Normal"
            $objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "Normal"
        Case "Low"
            $objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "Low"
    EndSwitch
    $objEmail.Fields.Update
    ; Sent the Message
    $objEmail.Send
    If @error Then
        SetError(2)
        Return $oMyRet[1]
    EndIf
    $objEmail=""
EndFunc   ;==>_INetSmtpMailCom

; Com Error Handler
Func MyErrFunc()
    $HexNumber = Hex($oMyError.number, 8)
    $oMyRet[0] = $HexNumber
    $oMyRet[1] = StringStripWS($oMyError.description, 3)
    ConsoleWrite("### COM Error !  Number: " & $HexNumber & "   ScriptLine: " & $oMyError.scriptline & "   Description:" & $oMyRet[1] & @LF)
    SetError(1); something to check for when this function returns
    Return
EndFunc   ;==>MyErrFunc
Edited by Yorn
Link to comment
Share on other sites

Here's the code of what I got working in case it helps anyone wanting to expand on this method. I made a sort of "service-like" program that triggers messages to show as tray tips as they come in. This was primarily intended to be a program that lets me remotely reboot computers on our network just by using a cell phone to text/email a specific address. It worked really well, in fact, but I'm not sure if it will work on Windows 7 or XP. I have 32-bit Vista.

Just load up your own Gmail $Username and $Password and text/email it with "@gmail.com" to test after running.

#include <Array.au3>
#include <String.au3>
#include <file.au3>
#include <INet.au3>
Global $Username = ""
Global $Password = ""
Global $entry, $Count, $PreviousCount
Global $oMyRet[2]
Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc")

$Response = _INetGetSource("https://" & $Username & ":" & $Password & "@" & "gmail.google.com/gmail/feed/atom")
$PreviousCount = _StringBetween($Response,"<fullcount>","</fullcount>")

While 1
    $Response = _INetGetSource("https://" & $Username & ":" & $Password & "@" & "gmail.google.com/gmail/feed/atom")
    $Count = _StringBetween($Response,"<fullcount>","</fullcount>")
    If $Count[0] > $PreviousCount[0] Then
        $Response = _INetGetSource("https://" & $Username & ":" & $Password & "@" & "gmail.google.com/gmail/feed/atom")
        $Array = _StringBetween($Response,"<entry>","</entry>")
        _ArrayReverse($Array)
        $entry = _ArrayPop($Array)
        $Summary = _StringBetween($entry,"<summary>","</summary>")
        $Sender = _StringBetween($entry,"<email>","</email>")
        TrayTip($Sender[0],$Summary[0], 10, 16)
        _SendEmail($Sender[0],"Message recieved!")
        ;Run("shutdown /r /m \\" & $Summary[0])
        $PreviousCount[0] = $Count[0]
        Sleep(5000)
    Elseif $Count[0] < $PreviousCount[0] Then
        $PreviousCount[0] = $Count[0]
        TrayTip("Count", "Changed to " & $PreviousCount[0], 10, 16)
        Sleep(5000)
    EndIf
    Sleep(15000)
    TrayTip("Count", "No Change from " & $Count[0], 10, 16)
    Sleep(10000)
WEnd

Func _SendEmail($inc_ToAddress,$inc_Body)
    $SmtpServer = "smtp.gmail.com"          ; address for the smtp-server to use - REQUIRED
    $FromName = $Username                   ; name from who the email was sent
    $FromAddress = $Username & "@gmail.com" ; address from where the mail should come
    $ToAddress = $inc_ToAddress             ; destination address of the email - REQUIRED
    $Subject = ""                           ; subject from the email - can be anything you want it to be
    $Body = $inc_Body                       ; the messagebody from the mail - can be left blank but then you get a blank mail
    $AttachFiles = ""                       ; the file(s) you want to attach seperated with a ; (Semicolon) - leave blank if not needed
    $CcAddress = ""                         ; address for cc - leave blank if not needed
    $BccAddress = ""                        ; address for bcc - leave blank if not needed
    $Importance = "Normal"                  ; Send message priority: "High", "Normal", "Low"
    ;Two entries are defined above as Globals
    ;$Username = "******"                   ; username for the account used from where the mail gets sent - REQUIRED
    ;$Password = "********"                 ; password for the account used from where the mail gets sent - REQUIRED
    ;We are using GMAIL so the following have to be commented out
    ;$IPPort = 25                           ; port used for sending the mail
    ;$ssl = 0                               ; enables/disables secure socket layer sending - put to 1 if using httpS
    ;And these need uncommented
    $IPPort=465                             ; GMAIL port used for sending the mail
    $ssl=1                                  ; GMAILenables/disables secure socket layer sending - put to 1 if using httpS

    Return _INetSmtpMailCom($SmtpServer, $FromName, $FromAddress, $ToAddress, $Subject, $Body, $AttachFiles, $CcAddress, $BccAddress, $Importance, $Username, $Password, $IPPort, $ssl)

EndFunc

Func _INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject = "", $as_Body = "", $s_AttachFiles = "", $s_CcAddress = "", $s_BccAddress = "", $s_Importance="Normal", $s_Username = "", $s_Password = "", $IPPort = 25, $ssl = 0)
    Local $objEmail = ObjCreate("CDO.Message")
    $objEmail.From = '"' & $s_FromName & '" <' & $s_FromAddress & '>'
    $objEmail.To = $s_ToAddress
    Local $i_Error = 0
    Local $i_Error_desciption = ""
    If $s_CcAddress <> "" Then $objEmail.Cc = $s_CcAddress
    If $s_BccAddress <> "" Then $objEmail.Bcc = $s_BccAddress
    $objEmail.Subject = $s_Subject
    If StringInStr($as_Body, "<") And StringInStr($as_Body, ">") Then
        $objEmail.HTMLBody = $as_Body
    Else
        $objEmail.Textbody = $as_Body & @CRLF
    EndIf
    If $s_AttachFiles <> "" Then
        Local $S_Files2Attach = StringSplit($s_AttachFiles, ";")
        For $x = 1 To $S_Files2Attach[0]
            $S_Files2Attach[$x] = _PathFull($S_Files2Attach[$x])
            ConsoleWrite('@@ Debug(62) : $S_Files2Attach = ' & $S_Files2Attach & @LF & '>Error code: ' & @error & @LF) ;### Debug Console
            If FileExists($S_Files2Attach[$x]) Then
                $objEmail.AddAttachment ($S_Files2Attach[$x])
            Else
                ConsoleWrite('!> File not found to attach: ' & $S_Files2Attach[$x] & @LF)
                SetError(1)
                Return 0
            EndIf
        Next
    EndIf
    $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = $s_SmtpServer
    If Number($IPPort) = 0 then $IPPort = 25
    $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = $IPPort
    ;Authenticated SMTP
    If $s_Username <> "" Then
        $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
        $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = $s_Username
        $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = $s_Password
    EndIf
    If $ssl Then
        $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
    EndIf
    ;Update settings
    $objEmail.Configuration.Fields.Update
    ; Set Email Importance
    Switch $s_Importance
        Case "High"
            $objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "High"
        Case "Normal"
            $objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "Normal"
        Case "Low"
            $objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "Low"
    EndSwitch
    $objEmail.Fields.Update
    ; Sent the Message
    $objEmail.Send
    If @error Then
        SetError(2)
        Return $oMyRet[1]
    EndIf
    $objEmail=""
EndFunc   ;==>_INetSmtpMailCom

; Com Error Handler
Func MyErrFunc()
    $HexNumber = Hex($oMyError.number, 8)
    $oMyRet[0] = $HexNumber
    $oMyRet[1] = StringStripWS($oMyError.description, 3)
    ConsoleWrite("### COM Error !  Number: " & $HexNumber & "   ScriptLine: " & $oMyError.scriptline & "   Description:" & $oMyRet[1] & @LF)
    SetError(1); something to check for when this function returns
    Return
EndFunc   ;==>MyErrFunc

I obtain that when i try your script:

D:\Program Files\Ride Runner\Skins\Carwings_Dynamic_pm_new\Scripts\WakeOnLan\essai.au3 (17) : ==> Subscript used with non-Array variable.:

If $Count[0] > $PreviousCount[0] Then

If $Count^ ERROR

Link to comment
Share on other sites

  • 1 month later...

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 ?

Hi,

May I ask you how you modified the atom feed string to get it to work with a Google Apps domain?

The script works very well (AutoIt 3.3.6.1, Win7 x64) reading a standard Gmail account feed, but with a Google Apps one, _InetGetSource returns an empty string.

Thx,

Luca

Link to comment
Share on other sites

  • 3 weeks later...
  • 2 weeks later...

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Tidy_Stop_onerror=n
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <ListBoxConstants.au3>
#include <StructureConstants.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
#include <GuiEdit.au3>
#include <GuiMenu.au3>
#include <File.au3>
#include <INet.au3>
#include <String.au3>
#include <TabConstants.au3>
#include <Misc.au3>
Global $GMailXML = ""
Global $Authorized = False
Global $NoEmail = True
Global $Response
Dim $aEmailXML[1]
Dim $aEmailTitles[1]
Dim $aEmailSummaries[1]
Dim $aEmailTimes[1]
Dim $aEmailDates[1]
Dim $aEmailFromNames[1]
Dim $aEmailFromEmails[1]
Global Const $GUIScale = .8
Global $CurrentMessage = 0
Global $user32dll = DllOpen("user32.dll")
Const $MMM = "The Mini Mailer"
Global $Newsletter = FileRead("Newsletter.txt")
Global $ExpDate = FileRead("Expirydate.txt")
Global $Thanks = FileRead("Thankyou.txt")
Global $Tdiff = IniRead('Settings.ini', 'Settings', 'Refresh_rate', '')
Global $GUIWidth, $GUIHeight, $timerinit, $oHTTP, $Password, $Username
Global $LeftArrow, $RightArrow
Global $LeftArrowPoints[5][2] = [[3]], $RightArrowPoints[5][2] = [[3]]
Global $GMailIconPos[4], $LeftArrowPos[4], $RightArrowPos[4], $ClosePos[4]
Global $hBackgroundImage
Dim $frmMain, $cmdSend, $ListedFriends, $txtAddAddr, $txtSubject, $OutGoingMSG, $ListedFriendscontext, $ClickandAdd, $ClickandRemove, $delallAddr
Dim $eTo, $eSubj, $eBody, $oOApp, $oOMail, $FL, $Line
Dim $nMsg, $Res, $SelectedListItem, $i, $CountList, $OkToSend
Global $oMyRetEmail[2]
Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc")
Global $SmtpServer, $FromName, $FromAddress, $ToAddress, $Subject, $Body, $AttachFiles, $CcAddress, $BccAddress, $Importance, $IPPort, $ssl
Global $MailAcc =     <<<<<<<<<<<<<<<<   PUT YOUR MAIL ACC HERE
Global $PWD =         <<<<<<<<<<<<<<<<   PUT YOUR PASSWORD HERE
Global $UN =          <<<<<<<<<<<<<<<<   PUT YOUR UNSERNAME HERE E.G. EMAIL WITHOUTH @GMAIL.COM
Global $EXPtemplet
Global $TYtemplet
Global $Newstemplet, $TempTo, $Temp
Global $MailPass, $rc, $objEmail, $HexNumber, $ToAttach, $iOld, $oldImage, $GC, $newImage, $newGC
Global $ColourSelect = IniRead('Settings.ini', 'Settings', 'Color_Set', '')
Global $Listcolorcolor, $font, $Backcolor, $Textcolor, $setGUIcolor, $Buttoncolor, $DownButton
Global $frmMain = GUICreate($MMM, 478, 338, -1, -1)
Global $cmdSend = GUICtrlCreateButton("Send", 380, 8, 90, 30, $BS_PUSHLIKE)
Global $AttachFile = GUICtrlCreateButton("Attach file", 380, 42, 90, 30, $BS_PUSHLIKE)
Global $ClearInputs = GUICtrlCreateButton("Clear", 380, 76, 90, 30, $BS_PUSHLIKE)
Global $ExitMail = GUICtrlCreateButton("Exit", 380, 110, 90, 30, $BS_PUSHLIKE)
Global $ButtonRemFriend = GUICtrlCreateButton("Remove friend", 380, 144, 90, 30, $BS_PUSHLIKE)
Global $ButtonAddFriend = GUICtrlCreateButton("Add friend", 380, 178, 90, 30, $BS_PUSHLIKE)
Global $MiniAdd = GUICtrlCreateButton("", 460, 300, 10, 10, $BS_PUSHLIKE)
$ListedFriends = GUICtrlCreateList("", 8, 8, 129, 176, BitOR($LBS_SORT, $LBS_MULTIPLESEL))
$ListedFriendscontext = GUICtrlCreateContextMenu($ListedFriends)
$ClickandAdd = GUICtrlCreateMenuItem("Add Address to list?", $ListedFriendscontext)
$ClickandRemove = GUICtrlCreateMenuItem("Delete selected Address?", $ListedFriendscontext)
Global $txtAddAddr = GUICtrlCreateInput("", 8, 186, 129, 21)
Global $txtSubject = GUICtrlCreateInput("", 144, 8, 230, 21)
Global $OutGoingMSG = GUICtrlCreateEdit("", 144, 32, 230, 177, BitOR($ES_MULTILINE, $ES_AUTOVSCROLL,$WS_VSCROLL), $WS_EX_CLIENTEDGE)
Global $Next = GUICtrlCreateButton(">>>", 330, 214, 45, 30, $BS_PUSHLIKE)
Global $Previous = GUICtrlCreateButton("<<<", 276, 214, 45, 30, $BS_PUSHLIKE)
Global $AdminConn = GUICtrlCreateButton("Connect", 380, 214, 90, 30, $BS_PUSHLIKE)
Global $TY = GUICtrlCreateButton("Thank you", 146, 222, 60, 18, $BS_PUSHLIKE)
Global $EXPNotice = GUICtrlCreateButton("Exp notice", 82, 222, 60, 18, $BS_PUSHLIKE)
Global $News = GUICtrlCreateButton("News letter", 18, 222, 60, 18, $BS_PUSHLIKE)
Global $EmailCount = GUICtrlCreateLabel("", 222, 225, 50, 22,$SS_CENTER)
GUICtrlSetColor(-1, 0x000000)
Global $EmailTitle = GUICtrlCreateLabel(" ", 282, 275, 180, 22,$SS_SIMPLE)
GUICtrlSetFont($EmailTitle, 9)
GUICtrlSetColor($EmailTitle, 0x000000)
Global $EmailFromName = GUICtrlCreateLabel("", 282, 295, 180, 22, $SS_SIMPLE)
GUICtrlSetColor($EmailFromName, 0x000000)
Global $EmailFromEmail = GUICtrlCreateLabel(" ", 282, 255, 180, 22, $SS_SIMPLE)
GUICtrlSetColor($EmailFromEmail, 0x000000)
Global $EmailBody = GUICtrlCreateInput(" ", 10, 250, 260, 58,BitOR($ES_MULTILINE, $ES_AUTOVSCROLL,$WS_VSCROLL), $WS_EX_CLIENTEDGE)
GUICtrlSetColor($EmailBody, 0x000000)
GUICtrlSetFont($EmailBody, 10)
GUICtrlCreateGroup('Load templet', 10, 208,204,36)
GUICtrlCreateGroup('Emails', 220, 208,50,36)
Global $mFile = GUICtrlCreateMenu("File")
Global $mX = GUICtrlCreateMenuItem("Exit",$mFile)
Global $mOptions = GUICtrlCreateMenu("Options")
Global $mCheckMail = GUICtrlCreateMenuItem("Check for new mail",$mOptions)
GUICtrlSetState(-1, $GUI_FOCUS)
_Setscheme()
GetFriendslist()
UpdateGMail()
SetEmailText()
GUISetBkColor($setGUIcolor, $frmMain)
GUICtrlSetBkColor($MiniAdd, $Buttoncolor)
GUICtrlSetBkColor($AdminConn, $Buttoncolor)
GUICtrlSetFont($AdminConn, 10, 800, 0, $font)
GUICtrlSetBkColor($Next, $Buttoncolor)
GUICtrlSetBkColor($Previous, $Buttoncolor)
GUICtrlSetBkColor($TY, $Buttoncolor)
GUICtrlSetBkColor($EXPNotice, $Buttoncolor)
GUICtrlSetBkColor($News, $Buttoncolor)
GUICtrlSetFont($txtSubject, 10, 800, 0, $font)
GUICtrlSetBkColor($txtSubject, $Listcolorcolor)
GUICtrlSetFont($cmdSend, 10, 800, 0, $font)
GUICtrlSetBkColor($cmdSend, $Buttoncolor)
GUICtrlSetFont($ClearInputs, 10, 800, 0, $font)
GUICtrlSetBkColor($ClearInputs, $Buttoncolor)
GUICtrlSetFont($ExitMail, 10, 800, 0, $font)
GUICtrlSetBkColor($ExitMail, $Buttoncolor)
GUICtrlSetFont($AttachFile, 10, 800, 0, $font)
GUICtrlSetBkColor($AttachFile, $Buttoncolor)
GUICtrlSetFont($ButtonRemFriend, 10, 800, 0, $font)
GUICtrlSetBkColor($ButtonRemFriend, $Buttoncolor)
GUICtrlSetFont($ButtonAddFriend, 10, 800, 0, $font)
GUICtrlSetBkColor($ButtonAddFriend, $Buttoncolor)
GUICtrlSetFont($OutGoingMSG, 10, -1, -1, $font)
GUICtrlSetBkColor($OutGoingMSG, $Backcolor)
GUICtrlSetBkColor($ListedFriends, $Listcolorcolor)
GUICtrlSetBkColor($EmailBody, $Listcolorcolor)
GUICtrlSetFont($News, 8)
GUICtrlSetFont($EXPNotice, 8)
GUICtrlSetFont($TY, 8)
GUICtrlSetTip($ClearInputs, "Clear inputs and unattach file")
GUICtrlSetTip($ButtonRemFriend, "Click here to remove your friend from the list")
GUICtrlSetTip($ButtonAddFriend, "Click here to add your friend to the list")
GUICtrlSetTip($AttachFile, "Attach file before typing")
GUICtrlSetTip($ExitMail, "Are you done sending out your emails?")
GUICtrlSetTip($ListedFriends, "Send email to :")
GUICtrlSetTip($cmdSend, "Send email")
GUICtrlSetTip($txtAddAddr, "Enter a friends email address here and click add")
GUICtrlSetTip($txtSubject, "The subject of the email is :")
GUICtrlSetData($OutGoingMSG, "")
GUICtrlSetTip($OutGoingMSG, "What would you like to say today?")
GUICtrlSetTip($MiniAdd, "Add the current email address to contact list?")
GUISetState(@SW_SHOW)
$timerinit = TimerInit()
While 1
    $nMsg = GUIGetMsg()
    $OkToSend = True
    If _IsPressed("0D", $user32dll) And WinActive($frmMain) Then
        Send(@CRLF, $OutGoingMSG)
    EndIf
    if TimerDiff($timerinit) > $Tdiff Then
        UpdateGMail()
        SetEmailText()
        $timerinit = TimerInit()
    EndIf
    Switch $nMsg
        Case $MiniAdd
            _GUICtrlListBox_AddString($ListedFriends, GetEmailEmail($CurrentMessage))
        Case $EXPNotice
            _EXPTemplet()
        Case $TY
            _TYTemplet()
        Case $News
            _News()
        Case $Previous
            LeftArrowPressed()
        Case $Next
            RightArrowPressed()
        Case $GUI_EVENT_CLOSE, $mX, $ExitMail
            DllClose($user32dll)
            WriteFriendslist()
            Exit
        Case $AdminConn
            ShellExecute("AdminClient.au3")
        Case $AttachFile
            $ToAttach = FileOpenDialog("Poker bot chat : Select file", @ScriptDir, "All Files (*.*)")
            GUICtrlSetData($OutGoingMSG,$ToAttach)
        Case $ClearInputs
            $ToAttach = ""
            GUICtrlSetData($OutGoingMSG, "")
            GUICtrlSetData($txtSubject, "")
        Case $ButtonAddFriend
            $SelectedListItem = GUICtrlRead($txtAddAddr)
            If StringLen($SelectedListItem) > 0 Then
                If StringInStr($SelectedListItem, "@") = 0 Or StringInStr($SelectedListItem, ".") = 0 Then
                    MsgBox(0, $MMM, "The address you have entered is not valid")
                Else
                    _GUICtrlListBox_AddString($ListedFriends, $SelectedListItem)
                EndIf
            EndIf
            GUICtrlSetData($txtAddAddr,"")
        Case $ButtonRemFriend
            If _GUICtrlListBox_GetSelCount($ListedFriends) > 0 Then
                $CountList = MsgBox(4, $MMM, "Remove the selected addresses?")
                If $CountList = 6 Then
                    Do
                        $SelectedListItem = _GUICtrlListBox_GetSelItems($ListedFriends)
                        If $SelectedListItem[0] > 0 Then
                            $CountList = 0
                            _GUICtrlListBox_DeleteString($ListedFriends, $SelectedListItem[1])
                        Else
                            $CountList = 1
                        EndIf
                    Until $CountList = 1
                EndIf
            EndIf
        Case $ClickandAdd
            $SelectedListItem = GUICtrlRead($txtAddAddr)
            If StringLen($SelectedListItem) > 0 Then
                If StringInStr($SelectedListItem, "@") = 0 Or StringInStr($SelectedListItem, ".") = 0 Then
                    MsgBox(64, $MMM, "The address you have entered is not valid")
                Else
                    _GUICtrlListBox_AddString($ListedFriends, $SelectedListItem)
                    ControlSetText("", "", 8, "")
                EndIf
            EndIf
        Case $ClickandRemove
            If _GUICtrlListBox_GetSelCount($ListedFriends) > 0 Then
                $CountList = MsgBox(4, $MMM, "Remove the selected addresses?")
                If $CountList = 6 Then
                    Do
                        $SelectedListItem = _GUICtrlListBox_GetSelItems($ListedFriends)
                        If $SelectedListItem[0] > 0 Then
                            $CountList = 0
                            _GUICtrlListBox_DeleteString($ListedFriends, $SelectedListItem[1])
                        Else
                            $CountList = 1
                        EndIf
                    Until $CountList = 1
                EndIf
            EndIf
        Case $cmdSend
            $SelectedListItem = _GUICtrlListBox_GetSelItemsText($ListedFriends)
            If $SelectedListItem[0] = 0 Then
                MsgBox(16, $MMM, "Please select a address from the list to email")
                $OkToSend = False
            ElseIf $SelectedListItem[0] = 1 Then
                $eTo = $SelectedListItem[1]
            Else
                $eTo = $SelectedListItem[1]
                For $i = 2 To $SelectedListItem[0]
                    $eTo = $eTo & "; " & $SelectedListItem[$i]
                Next
            EndIf
            $eSubj = GUICtrlRead($txtSubject)
            $eBody = GUICtrlRead($OutGoingMSG)
            $SmtpServer = "smtp.gmail.com"
            $FromName = $UN
            $FromAddress = $MailAcc
            $ToAddress = $eTo
            $Subject = $eSubj
            $Body = " " & $eBody & " "
            $AttachFiles = $ToAttach
            $CcAddress = ""
            $BccAddress = ""
            $Importance = "Normal"
            $IPPort = 465
            $ssl = 1
            If $OkToSend = True and $SelectedListItem[0] >= 0 Then
                Switch MsgBox(4, "Password", "Is your Betabot password the same as your Gmail password?")
                    Case 6
                        $MailPass = $PWD
                    case 7
                        $MailPass = InputBox("Gmail password", "Please enter your Gmail password")
                EndSwitch
                $Username = $MailAcc
                $Password = $MailPass
                $rc = _INetSmtpMailCom($SmtpServer, $FromName, $FromAddress, $ToAddress, $Subject, $Body, $AttachFiles, $CcAddress, $BccAddress, $Importance, $Username, $Password, $IPPort, $ssl)
                If @error Then
                    MsgBox(0, "Error sending message", "Error code:" & @error & "  Description:" & $rc)
                ElseIf Not @error Then
                    GUICtrlSetData($txtSubject,"")
                    GUICtrlSetData($OutGoingMSG,"")
                    $ToAttach = ""
                EndIf
            EndIf
            If $Res = True Then
                ControlSetText("", "", 3, "Message sent")
                Sleep(2000)
                ControlSetText("", "", 3, "Send")
            EndIf
    EndSwitch
WEnd

Func _EXPTemplet()
    if FileExists("Expirydate.txt") Then
        $TempTo = GUICtrlRead($EmailFromEmail)
        $Temp = StringTrimLeft($TempTo,6)
        $EXPtemplet = "Hello, " & $Temp & @CRLF & @CRLF & $ExpDate ;& @LF & "You can
        GUICtrlSetData($txtAddAddr, $TempTo)
        GUICtrlSetData($OutGoingMSG, $EXPtemplet)
    Else
        MsgBox(0, "No Expirydate.txt", "No expiry date file found, a new file will be created.")
        FileWrite("Expirydate.txt", " ")
        ShellExecute("Expirydate.txt")
    EndIf
EndFunc

Func _TYTemplet()
    if FileExists("Thankyou.txt") Then
        $TempTo = GUICtrlRead($EmailFromEmail)
        $Temp = StringTrimLeft($TempTo,6)
        $TYtemplet = "Thank you for your donation" & $Temp & "." & @CRLF & @CRLF & $Thanks
        GUICtrlSetData($txtAddAddr, $TempTo)
        GUICtrlSetData($OutGoingMSG, $TYtemplet)

    Else
        MsgBox(0, "No Thankyou.txt", "No thank you file found, a new file will be created.")
        FileWrite("Thankyou.txt", " ")
        ShellExecute("Thankyou.txt")
    EndIf

EndFunc

Func _News()
    if FileExists("Newsletter.txt") Then
        $TempTo = GUICtrlRead($EmailFromEmail)
        $Temp = StringTrimLeft($TempTo,6)
        $Newstemplet = "Hello" & $Temp & "," & @CRLF & @CRLF & "" & $Newsletter
        GUICtrlSetData($txtAddAddr, $TempTo)
        GUICtrlSetData($OutGoingMSG, $Newstemplet)
    Else
        MsgBox(0, "No Newsletter.txt", "No newsletter file found, a new file will be created.")
        FileWrite("Newsletter.txt", " ")
        ShellExecute("Newsletter.txt")
    EndIf
EndFunc

Func _INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject = "", $as_Body = "", $s_AttachFiles = "", $s_CcAddress = "", $s_BccAddress = "", $s_Importance="Normal", $s_Username = "", $s_Password = "", $IPPort = 25, $ssl = 0)
    Local $objEmail = ObjCreate("CDO.Message")
    $objEmail.From = '"' & $s_FromName & '" <' & $s_FromAddress & '>'
    $objEmail.To = $s_ToAddress
    Local $i_Error = 0
    Local $i_Error_desciption = ""
    If $s_CcAddress <> "" Then $objEmail.Cc = $s_CcAddress
    If $s_BccAddress <> "" Then $objEmail.Bcc = $s_BccAddress
    $objEmail.Subject = $s_Subject
    If StringInStr($as_Body, "<") And StringInStr($as_Body, ">") Then
        $objEmail.HTMLBody = $as_Body
    Else
        $objEmail.Textbody = $as_Body & @CRLF
    EndIf
    If $s_AttachFiles <> "" Then
        Local $S_Files2Attach = StringSplit($s_AttachFiles, ";")
        For $x = 1 To $S_Files2Attach[0]
            $S_Files2Attach[$x] = _PathFull($S_Files2Attach[$x])
            ConsoleWrite('@@ Debug(62) : $S_Files2Attach = ' & $S_Files2Attach & @LF & '>Error code: ' & @error & @LF) ;### Debug Console
            If FileExists($S_Files2Attach[$x]) Then
                $objEmail.AddAttachment ($S_Files2Attach[$x])
            Else
                ConsoleWrite('!> file not found to attach: ' & $S_Files2Attach[$x] & @LF)
                SetError(1)
                Return 0
            EndIf
        Next
    EndIf
    $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = $s_SmtpServer
    If Number($IPPort) = 0 then $IPPort = 25
    $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = $IPPort
    If $s_Username <> "" Then
        $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
        $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = $s_Username
        $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = $s_Password
    EndIf
    If $ssl Then
        $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
    EndIf
    $objEmail.Configuration.Fields.Update
    Switch $s_Importance
        Case "High"
            $objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "High"
        Case "Normal"
            $objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "Normal"
        Case "Low"
            $objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "Low"
    EndSwitch
    $objEmail.Fields.Update
    $objEmail.Send
    If @error Then
        SetError(2)
        Return $oMyRetEmail[1]
    EndIf
    $objEmail=""
EndFunc   ;==>_INetSmtpMailCom

Func MyErrFunc()
    $HexNumber = Hex($oMyError.number, 8)
    $oMyRetEmail[0] = $HexNumber
    $oMyRetEmail[1] = StringStripWS($oMyError.description, 3)
    ConsoleWrite("### COM Error ! Number: " & $HexNumber & " ScriptLine: " & $oMyError.scriptline & " Description:" & $oMyRetEmail[1] & @LF)
    SetError(1)
    Return
EndFunc   ;==>MyErrFunc

Func GetFriendslist()
    $FL = FileOpen("Friendslist.ini", 0)
    If $FL = -1 Then

    Else
        While 1
            $Line = FileReadLine($FL)
            If @error = -1 Then ExitLoop
            _GUICtrlListBox_AddString($ListedFriends, $Line)
        WEnd
        FileClose($FL)
    EndIf
EndFunc   ;==>GetFriendslist

Func WriteFriendslist()
    $FL = FileOpen("Friendslist.ini", 2)
    $CountList = _GUICtrlListBox_GetCount($ListedFriends)
    If $CountList > 0 Then
        For $i = 0 to ($CountList - 1)
            $Line = _GUICtrlListBox_GetText($ListedFriends, $i)
            FileWriteLine($FL, $Line & @CRLF)
        Next
    EndIf
    FileClose($FL)
EndFunc   ;==>WriteFriendslist

Func SetEmailText()
    If GetCount() = 0 Then
        GUICtrlSetData($EmailCount, " ")
        GUICtrlSetData($EmailTitle, " ")
        GUICtrlSetData($EmailFromName, " ")
        GUICtrlSetData($EmailFromEmail, "No new email")
        GUICtrlSetData($EmailBody, " ")
    ElseIf GetAuthorized() Then
        GUICtrlSetData($EmailCount, ($CurrentMessage + 1) & " / " & GetCount())
        GUICtrlSetData($EmailTitle, "Subject : " & GetEmailTitle($CurrentMessage))
        GUICtrlSetData($EmailFromName, "Contact name : " & GetEmailName($CurrentMessage))
        GUICtrlSetData($EmailFromEmail, "From : " & GetEmailEmail($CurrentMessage))
        GUICtrlSetData($EmailBody, "")
        _GUICtrlEdit_AppendText($EmailBody, GetEmailSummary($CurrentMessage))
    Else
        GUICtrlSetData($EmailCount, " ")
        GUICtrlSetData($EmailTitle, " ")
        GUICtrlSetData($EmailFromName, " ")
        GUICtrlSetData($EmailFromEmail, " ")
        GUICtrlSetData($EmailBody, " ")
    EndIf
EndFunc   ;==>SetEmailText

Func UpdateGMail()
    Global $Username = IniRead('Settings.ini', 'Settings', 'Admin_account', '')
    Global $Password = IniRead('Settings.ini', 'Settings', 'Admin_password', '')
    UpdateGMailXML($Username, $Password)
    Switch @error
        Case 1
            ;invalid login information
            MsgBox(262192, "GMail Error", "The login information you provided is not valid")
            ;Exit
        Case 2
            ;no unread email
        Case Else
            If IsDeclared("Background_GUI") Then SetEmailText()
    EndSwitch
EndFunc   ;==>UpdateGMail

Func LeftArrowPressed()
    If $CurrentMessage + 1 > 1 Then
        $CurrentMessage -= 1
        SetEmailText()
    EndIf
EndFunc   ;==>LeftArrowPressed

Func RightArrowPressed()
    If $CurrentMessage + 1 < GetCount() Then
        $CurrentMessage += 1
        SetEmailText()
    EndIf
EndFunc   ;==>RightArrowPressed

Func UpdateGmailXML($Username, $Password)
    If @OSVersion = "WIN_7" Then
        $Response = _INetGetSource("https://" & $Username & ":" & $Password & "@" & "gmail.google.com/gmail/feed/atom")
    Else
        $oHTTP = ObjCreate("winhttp.winhttprequest.5.1")
        $oHTTP.Open("GET", "https://gmail.google.com/gmail/feed/atom", False)
        $oHTTP.SetCredentials($Username, $Password, 0)
        $oHTTP.Send()
        Local $Response = $oHTTP.ResponseText
    EndIf
    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

Func Time24To12($String)
    Local $Split = StringSplit($String, ":", 2)
    Local $iHour = $Split[0]
    Local $iMin = $Split[1]
    Local $sAMPM = "AM"
    If $iHour >= 12 Then $sAMPM = "PM"
    If $iHour = 00 Then $iHour = 12
    If $iHour > 12 Then $iHour -= 12
    If $iMin < 10 Then $iMin = "0" & Int($iMin)
    Return Int($iHour) & ":" & String($iMin) & " " & $sAMPM
EndFunc   ;==>Time24To12

Func DateFromTimeDate($String)
    Local $RegEx = StringRegExp($String, "(?<Year>\d{2}|\d{4})(?:-)(?<Month>\d{1,2})(?:-)(?<Day>\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, "(?<Hour>\d{1,2})(?::)(?<Minute>\d{1,2})(?::)(?<Second>\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
#EndRegion INTERNAL FUNCTIONS

Func GetAuthorized()
    Return $Authorized
EndFunc   ;==>GetAuthorized

Func GetNoEmail()
    Return $NoEmail
EndFunc

Func GetGmailXML()
    If Not $Authorized Then Return ""
    Return String($GMailXML)
EndFunc   ;==>GetGmailXML

Func GetTitle()
    If Not $Authorized Then Return ""
    Return String(sStringBetween($GMailXML, "<title>", "</title>"))
EndFunc   ;==>GetTitle

Func GetCount()
    If Not $Authorized Then Return ""
    If $NoEmail Then Return 0
    Return Int(sStringBetween($GMailXML, "<fullcount>", "</fullcount>"))
EndFunc   ;==>GetCount

Func GetEmailName($index)
    If Not $Authorized Or $NoEmail Then Return ""
    If $index > UBound($aEmailFromNames) - 1 Then Return SetError(1, 0, "")
    Return $aEmailFromNames[$index]
EndFunc   ;==>GetEmailName

Func GetEmailEmail($index)
    If Not $Authorized Or $NoEmail Then Return ""
    If $index > UBound($aEmailFromEmails) - 1 Then Return SetError(1, 0, "")
    Return $aEmailFromEmails[$index]
EndFunc   ;==>GetEmailEmail

Func GetEmailTitle($index)
    If Not $Authorized Or $NoEmail Then Return ""
    If $index > UBound($aEmailTitles) - 1 Then Return SetError(1, 0, "")
    Return $aEmailTitles[$index]
EndFunc   ;==>GetEmailTitle

Func GetEmailSummary($index)
    If Not $Authorized Or $NoEmail Then Return ""
    If $index > UBound($aEmailSummaries) - 1 Then Return SetError(1, 0, "")
    Return $aEmailSummaries[$index]
EndFunc   ;==>GetEmailSummary

Func GetEmailTime($index, $format = True)
    If Not $Authorized Or $NoEmail Then Return ""
    If $index > UBound($aEmailTimes) - 1 Then Return SetError(1, 0, "")
    If $format Then
        Return Time24To12($aEmailTimes[$index])
    Else
        Return $aEmailTimes[$index]
    EndIf
EndFunc   ;==>GetEmailTime

Func GetEmailDate($index)
    If Not $Authorized Or $NoEmail Then Return ""
    If $index > UBound($aEmailDates) - 1 Then Return SetError(1, 0, "")
        Return $aEmailDates[$index]
EndFunc   ;==>GetEmailDate

Func sStringBetween($s_String, $s_Start, $s_End, $v_Case = -1)
    Local $Between = _StringBetween($s_String, $s_Start, $s_End, $v_Case)
    If IsArray($Between) Then
        Return $Between[0]
    Else
        Return ""
    EndIf
EndFunc   ;==>sStringBetween

Func _Setscheme()
    If $ColourSelect = 'Red' Then
        $font = 'Calibri'
        $Backcolor = '0xf99799'
        $Textcolor = '0xea0005'
        $setGUIcolor = '0xff4f53'
        $Buttoncolor = '0xfdcdce'
        $Listcolorcolor = '0xfdeded'
    ElseIf $ColourSelect = 'BetaBot' Then
        $font = 'Calibri'
        $Backcolor = '0x9FD4FC'
        $Textcolor = '0x00000F'
        $setGUIcolor = '0xFFFBF0'
        $Buttoncolor = '0x0066CC'
        $Listcolorcolor = '0xF3FBFC'
    ElseIf $ColourSelect = 'Blue' Then
        $font = 'Calibri'
        $Backcolor = '0x83B4FC'
        $Textcolor = '0xFFFFFF'
        $setGUIcolor = '0xb7d9ff'
        $Buttoncolor = '0xb5e9f6'
        $Listcolorcolor = '0xb5e9f6'
    ElseIf $ColourSelect = 'Green' Then
        $font = 'Calibri'
        $Backcolor = '0xceedb3'
        $Textcolor = '0x5cc109'
        $setGUIcolor = '0xb5fc7a'
        $Buttoncolor = '0x7af03e'
        $Listcolorcolor = '0xe3fbcf'
    ElseIf $ColourSelect = 'Yellow' Then
        $font = 'Calibri'
        $Backcolor = '0xfbf7b5'
        $Textcolor = '0xFFFFFF'
        $setGUIcolor = '0xfbf781'
        $Buttoncolor = '0xf9fa68'
        $Listcolorcolor = '0xfefdc7'
    ElseIf $ColourSelect = 'Purple' Then
        $font = 'Calibri'
        $Backcolor = '0xe78be4'
        $Textcolor = '0xFFFFFF'
        $setGUIcolor = '0xf0c3f7'
        $Buttoncolor = '0xdf7cf0'
        $Listcolorcolor = '0xfae8fc'
    ElseIf $ColourSelect = 'Orange' Then
        $font = 'Calibri'
        $Backcolor = '0xf0b14e'
        $Textcolor = '0xFFFFFF'
        $setGUIcolor = '0xf9cf8d'
        $Buttoncolor = '0xf7b247'
        $Listcolorcolor = '0xfdedd3'
    ElseIf $ColourSelect = 'Dark' Then
        $font = 'Calibri'
        $Backcolor = '0x000000'
        $Textcolor = '0xcbcbcb'
        $setGUIcolor = '0x4b494d'
        $Buttoncolor = '0x636363'
        $Listcolorcolor = '0xd8d8d8'
    EndIf
EndFunc   ;==>_Setscheme

ok hey all, my first post. yay me. just thought id add my lil knock up using this method. dorry if the script is messy, im no pro

Link to comment
Share on other sites

its not letting me edit my post.

EDIT FOR PREVIOUS POST: i should add that this is pulled from a chat server/client program of mine so there may be som mods to made. (note)make up a setting.ini file ,

Add this to the top of the script if its needed

if not FileExists("Settings.ini") Then
$G = InputBox("Gmail Account", "Type in the gmail account to use")
IniWrite('Settings.ini', 'Settings', 'Admin_account', $G)
$P = InputBox("Gmail pass", "Type in the gmail password to use")
IniWrite('Settings.ini', 'Settings', 'Admin_password', $P)
$R = InputBox("Refresh rate", "Type in the amount of time in milliseconds")
IniWrite('Settings.ini', 'Settings', 'Refresh_rate', $R)
Iniwrite('Settings.ini', 'Settings', 'Color_Set', 'Green')
EndIf
Edited by Motuatronic2010
Link to comment
Share on other sites

  • 4 months later...
  • 1 month later...

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
 Share

  • Recently Browsing   0 members

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