[英]How to get Gmail subjects using Gmail API in C#
I am making an app that can get all the e-mails in Gmail Inbox from a C# console application. 我正在制作一个应用程序,可以从C#控制台应用程序获取Gmail收件箱中的所有电子邮件。
I have this code below that prints out the console the email body contents: 我在下面的代码中打印出控制台的电子邮件正文内容:
UsersResource.ThreadsResource.ListRequest threadRequest = service.Users.Threads.List("me");
IList<Google.Apis.Gmail.v1.Data.Thread> threads = threadRequest.Execute().Threads;
foreach(var thread in threads)
{
//print gmail body content
Console.WriteLine("{0}", thread.Snippet);
}
So how do I get gmail subjects instead? 那么我如何获得gmail主题呢? Any contribution will be appriciated!
任何贡献都会得到满足!
public string GetMail(){
GmailService service = (GmailService)HttpContext.Current.Session["service"];
Message messageFeed = service.Users.Messages.List("me").Execute().Messages.First();
UsersResource.MessagesResource.GetRequest getReq = new UsersResource.MessagesResource.GetRequest(service, "me", messageFeed.Id);
//"raw": Returns the full email message data with body content in the raw field as a base64url encoded string; the payload field is not used.
getReq.Format = UsersResource.MessagesResource.GetRequest.FormatEnum.Raw;
Message message = getReq.Execute();
return message.Raw;
}
Getting more data from messages.get in C# 从C#中的messages.get获取更多数据
Better solution: 更好的方案:
Read the Gmail Inbox Feed with .NET and OAuth 阅读带有.NET和OAuth的Gmail收件箱Feed
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.