AutoIt
AutoIt
Get a List of Message IDs in GMail User's Mailbox
See more GMail REST API Examples
Demonstrates how to get a list of message IDs in a GMail mailbox. The "userId" can be either the user's email address or the special value "me" to indicate the authenticated user.Chilkat AutoIt Downloads
Local $bSuccess = False
; This example requires the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.
$oHttp = ObjCreate("Chilkat.Http")
$oHttp.AuthToken = "ACCESS_TOKEN"
$oHttp.Accept = "application/json"
$oResp = ObjCreate("Chilkat.HttpResponse")
$bSuccess = $oHttp.HttpNoBody("GET","https://www.googleapis.com/gmail/v1/users/userId/messages",$oResp)
If ($bSuccess = False) Then
ConsoleWrite($oHttp.LastErrorText & @CRLF)
Exit
EndIf
ConsoleWrite("Response Status Code: " & $oResp.StatusCode & @CRLF)
$oJsonResponse = ObjCreate("Chilkat.JsonObject")
$oJsonResponse.Load($oResp.BodyStr)
$oJsonResponse.EmitCompact = False
ConsoleWrite($oJsonResponse.Emit() & @CRLF)
If ($oResp.StatusCode <> 200) Then
ConsoleWrite("Failed." & @CRLF)
Exit
EndIf
; {
; "messages": [
; users.messages Resource
; ],
; "nextPageToken": string,
; "resultSizeEstimate": unsigned integer
; }
Local $sId
Local $sThreadId
Local $iResultSizeEstimate = $oJsonResponse.IntOf("resultSizeEstimate")
Local $i = 0
Local $iCount_i = $oJsonResponse.SizeOfArray("messages")
While $i < $iCount_i
$oJsonResponse.I = $i
$sId = $oJsonResponse.StringOf("messages[i].id")
$sThreadId = $oJsonResponse.StringOf("messages[i].threadId")
$i = $i + 1
Wend