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 New Chilkat.Rest
Dim success As Boolean
' URL: https://www.googleapis.com/gmail/v1/users/me/messages?q=subject:ADVChina
Dim bTls As Boolean = True
Dim port As Integer = 443
Dim bAutoReconnect As Boolean = True
success = Await rest.ConnectAsync("www.googleapis.com",port,bTls,bAutoReconnect)
If (success <> True) Then
Debug.WriteLine("ConnectFailReason: " & rest.ConnectFailReason)
Debug.WriteLine(rest.LastErrorText)
Exit Sub
End If
rest.AddHeader("Authorization","Bearer GMAIL_TOKEN")
Dim sbResponseBody As New Chilkat.StringBuilder
success = Await rest.FullRequestNoBodySbAsync("GET","/gmail/v1/users/me/messages?q=subject:ADVChina",sbResponseBody)
If (success <> True) Then
Debug.WriteLine(rest.LastErrorText)
Exit Sub
End If
Dim respStatusCode As Integer = rest.ResponseStatusCode
If (respStatusCode >= 400) Then
Debug.WriteLine("Response Status Code = " & respStatusCode)
Debug.WriteLine("Response Header:")
Debug.WriteLine(rest.ResponseHeader)
Debug.WriteLine("Response Body:")
Debug.WriteLine(sbResponseBody.GetAsString())
Exit Sub
End If
Dim jsonResponse As New Chilkat.JsonObject
jsonResponse.LoadSb(sbResponseBody)
' See the Online Tool for Generating JSON Parse Code
Dim i As Integer
Dim count_i As Integer
Dim resultSizeEstimate As Integer = jsonResponse.IntOf("resultSizeEstimate")
i = 0
count_i = jsonResponse.SizeOfArray("messages")
While i < count_i
jsonResponse.I = i
Dim id As String = jsonResponse.StringOf("messages[i].id")
Dim threadId As String = jsonResponse.StringOf("messages[i].threadId")
i = i + 1
End While
{
"messages": [
{
"id": "166e50fed0b9b0cb",
"threadId": "166e50fed0b9b0cb"
},
{
"id": "166c12e5fee013fe",
"threadId": "166c12e5fee013fe"
},
{
"id": "1669cc9a926bb8c1",
"threadId": "1669cc9a926bb8c1"
},
{
"id": "16678c485e7f0a0c",
"threadId": "16678c485e7f0a0c"
}
],
"resultSizeEstimate": 4
}