Return messages matching the specified query. See https://support.google.com/mail/answer/7190?hl=en for additional information about search operators. This example searches for all emails having the whole word "ADVChina" in the subject.
curl -X GET https://www.googleapis.com/gmail/v1/users/me/messages?q=subject:ADVChina \
--header "Authorization: Bearer GMAIL_TOKEN"
Dim rest As Chilkat.Rest
Set rest = Chilkat.NewRest
' URL: https://www.googleapis.com/gmail/v1/users/me/messages?q=subject:ADVChina
bTls = True
port = 443
bAutoReconnect = True
success = rest.Connect("www.googleapis.com",port,bTls,bAutoReconnect)
If (success <> True) Then
Debug.Print "ConnectFailReason: "; rest.ConnectFailReason
Debug.Print rest.LastErrorText
Exit Sub
End If
success = rest.AddHeader("Authorization","Bearer GMAIL_TOKEN")
Dim sbResponseBody As Chilkat.StringBuilder
Set sbResponseBody = Chilkat.NewStringBuilder
success = rest.FullRequestNoBodySb("GET","/gmail/v1/users/me/messages?q=subject:ADVChina",sbResponseBody)
If (success <> True) Then
Debug.Print rest.LastErrorText
Exit Sub
End If
respStatusCode = rest.ResponseStatusCode
If (respStatusCode >= 400) Then
Debug.Print "Response Status Code = "; respStatusCode
Debug.Print "Response Header:"
Debug.Print rest.ResponseHeader
Debug.Print "Response Body:"
Debug.Print sbResponseBody.GetAsString()
Exit Sub
End If
Dim jsonResponse As Chilkat.JsonObject
Set jsonResponse = Chilkat.NewJsonObject
success = jsonResponse.LoadSb(sbResponseBody)
' See the Online Tool for Generating JSON Parse Code
resultSizeEstimate = jsonResponse.IntOf("resultSizeEstimate")
i = 0
count_i = jsonResponse.SizeOfArray("messages")
Do While i < count_i
jsonResponse.I = i
id = jsonResponse.StringOf("messages[i].id")
threadId = jsonResponse.StringOf("messages[i].threadId")
i = i + 1
Loop
{
"messages": [
{
"id": "166e50fed0b9b0cb",
"threadId": "166e50fed0b9b0cb"
},
{
"id": "166c12e5fee013fe",
"threadId": "166c12e5fee013fe"
},
{
"id": "1669cc9a926bb8c1",
"threadId": "1669cc9a926bb8c1"
},
{
"id": "16678c485e7f0a0c",
"threadId": "16678c485e7f0a0c"
}
],
"resultSizeEstimate": 4
}