本文整理汇总了C#中MailKit.Net.Imap.ImapEngine.ParseMessage方法的典型用法代码示例。如果您正苦于以下问题:C# ImapEngine.ParseMessage方法的具体用法?C# ImapEngine.ParseMessage怎么用?C# ImapEngine.ParseMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MailKit.Net.Imap.ImapEngine
的用法示例。
在下文中一共展示了ImapEngine.ParseMessage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FetchSummaryItems
//.........这里部分代码省略.........
if (token.Type == ImapTokenType.OpenParen) {
do {
token = engine.ReadToken (ic.CancellationToken);
if (token.Type == ImapTokenType.CloseParen)
break;
// the header field names will generally be atoms or qstrings but may also be literals
switch (token.Type) {
case ImapTokenType.Literal:
engine.ReadLiteral (ic.CancellationToken);
break;
case ImapTokenType.QString:
case ImapTokenType.Atom:
break;
default:
throw ImapEngine.UnexpectedToken (token, false);
}
} while (true);
} else if (token.Type != ImapTokenType.Atom) {
throw ImapEngine.UnexpectedToken (token, false);
}
} while (true);
if (token.Type != ImapTokenType.CloseBracket)
throw ImapEngine.UnexpectedToken (token, false);
token = engine.ReadToken (ic.CancellationToken);
if (token.Type != ImapTokenType.Literal)
throw ImapEngine.UnexpectedToken (token, false);
try {
var message = engine.ParseMessage (engine.Stream, false, ic.CancellationToken);
summary.Fields |= MessageSummaryItems.References;
summary.References = message.References;
summary.Headers = message.Headers;
} catch (FormatException) {
// consume any remaining literal data...
ReadLiteralData (engine, ic.CancellationToken);
}
} else {
summary.Fields |= MessageSummaryItems.Body;
try {
summary.Body = ImapUtils.ParseBody (engine, string.Empty, ic.CancellationToken);
} catch (ImapProtocolException ex) {
if (!ex.UnexpectedToken)
throw;
// Note: GMail's IMAP implementation sometimes replies with completely broken BODY values
// (see issue #32 for the `BODY ("ALTERNATIVE")` example), so to work around this nonsense,
// we need to drop the remainder of this line.
do {
token = engine.PeekToken (ic.CancellationToken);
if (token.Type == ImapTokenType.Eoln)
break;
token = engine.ReadToken (ic.CancellationToken);
if (token.Type == ImapTokenType.Literal)
ReadLiteralData (engine, ic.CancellationToken);
} while (true);
return;