[英]Gmail API ? how to request for an email using Gmail api with format of raw and how to convert it into normal String
Can anybody help me out in this? 有人可以帮助我吗? I'm working with
我正在和我一起工作
gmail-api where I need to read a email.
我需要阅读电子邮件的gmail-api 。 I have gone through the documentation of Gmail API for reading a messages, and I'm able to read email into RFC format.
我已经浏览了Gmail API的文档来阅读邮件,并且我能够将电子邮件读取为RFC格式。 How do I convert it to normal Text?
如何将其转换为普通文本?
If at all I need to use Java Libraries Mime classes for conversion, how do I use it specifically to read "From address", "To address" and "Message Body?" 如果我需要使用Java Libraries Mime类进行转换,我该如何专门用它来读取“From address”,“To address”和“Message Body?”
Once you have a raw (RFC822) email string you can use the java MimeMessage
library to parse it and then read the headers. 获得原始(RFC822)电子邮件字符串后,可以使用java
MimeMessage
库对其进行解析,然后读取标头。 I found a couple by searching for java MimeMessage example
. 我通过搜索
java MimeMessage example
找到了一对。 You can use the MimeMessage(Session, InputStream)
constructor, once you have a MimeMessage
you can just call things like getFrom()
or getHeader(String headerName)
on it. 您可以使用
MimeMessage(Session, InputStream)
构造函数,一旦有了MimeMessage
,就可以在其上调用getFrom()
或getHeader(String headerName)
的东西。
While not exactly what you're trying to do, the Gmail API java guide for sending email is somewhat relevant in that it shows how to deal with MimeMessage libraries, etc: 虽然不完全是你想要做的,但发送电子邮件的Gmail API java指南在某种程度上是相关的,因为它展示了如何处理MimeMessage库等:
https://developers.google.com/gmail/api/guides/sending https://developers.google.com/gmail/api/guides/sending
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.