1
我嘗試從發件箱中只得到郵件:Android版Gmail API獲取發件箱中的郵件
String user = "me";
ListMessagesResponse response = mService.users().messages().list(user).execute();
//set selected labels
//[CATEGORY_PERSONAL, CATEGORY_SOCIAL, Регистрации, CATEGORY_FORUMS, IMPORTANT, CATEGORY_UPDATES, CHAT, SENT, INBOX, TRASH, CATEGORY_PROMOTIONS, DRAFT, SPAM, STARRED, UNREAD]
List<String> labelIds = new ArrayList<>();
labelIds.add("SENT");
List<Message> messages = new ArrayList<Message>();
while (response.getMessages() != null) {
messages.addAll(response.getMessages());
if (response.getNextPageToken() != null) {
String pageToken = response.getNextPageToken();
response = mService.users().messages().list(user).setLabelIds(labelIds).setPageToken(pageToken).execute();
} else {
break;
}
}
,但我得到的消息收件箱中也
爲什麼你不'第一'ListMessagesResponse' setLabelIds'呢? – Tholle
謝謝@Tholle,這是正確的答案。 –