Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/320.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在C中使用Gmail API获取Gmail主题#_C#_Gmail_Gmail Api - Fatal编程技术网

C# 如何在C中使用Gmail API获取Gmail主题#

C# 如何在C中使用Gmail API获取Gmail主题#,c#,gmail,gmail-api,C#,Gmail,Gmail Api,我正在制作一个应用程序,可以从C#控制台应用程序中获取Gmail收件箱中的所有电子邮件 我在下面有一段代码,用于打印控制台中的电子邮件正文内容: UsersResource.ThreadsResource.ListRequest threadRequest = service.Users.Threads.List("me"); IList<Google.Apis.Gmail.v1.Data.Thread> threads = threadRequest.Execute().Threa

我正在制作一个应用程序,可以从C#控制台应用程序中获取Gmail收件箱中的所有电子邮件

我在下面有一段代码,用于打印控制台中的电子邮件正文内容:

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);
}
UsersResource.ThreadsResource.ListRequestThreadRequest=service.Users.Threads.List(“我”);
IList threads=threadRequest.Execute().threads;
foreach(线程中的var线程)
{
//打印gmail正文内容
WriteLine(“{0}”,thread.Snippet);
}
那么,我如何取而代之地获得gmail主题呢? 任何贡献都将受到感谢

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;
}

更好的解决方案:

更好的解决方案:


此问题以前问过,请检查此线程:此问题以前问过,请检查此线程: