GMail API retrieve From, To, etc. from a message?

岁酱吖の 提交于 2019-12-24 02:39:15

问题


How I can do to retrieve, from, to, subject, etc. from a message with this code ? Actually I can retrive list of message in a folder (label) but i want to retrieve fron, to, sender, etc. to display in a grid

Private Sub LoadMailGrid(ByVal FolderName As String)

        Dim request As Google.Apis.Gmail.v1.UsersResource.MessagesResource.ListRequest = myGMailService.Users.Messages.List("xxxxxxx@gmail.com")
        request.Q = "label: " + folderName
        Dim messagesList As ListMessagesResponse = request.Execute()

        Dim SubjectList As List(Of GMailMessageSummary) = New List(Of GMailMessageSummary)
        Dim mail As GMailMessageSummary

        For Each Message In messagesList.Messages
            mail = New GMailMessageSummary
            mail.MessageID = Message.Id
            **mail.From = Message.**
            mail.Subject = "Courriel " + x.ToString
            mail.Received = Today
            SubjectList.Add(mail)
        Next

        grdGMail.DataSource = SubjectList
        grdGMail.DataBind()

    End Sub

回答1:


List message just returns the message Ids and thread ids, not the full content (since that could be an entire email which could be huge like 25MB). So if you want certain info on all of them then call messages.get() in the loop. If you only want headers like To, From, Subject then you can call messages.get(format=METADATA), or however it looks in the language you're using.

https://developers.google.com/gmail/api/v1/reference/users/messages/get



来源:https://stackoverflow.com/questions/29980303/gmail-api-retrieve-from-to-etc-from-a-message

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!