当前位置: 首页>>代码示例>>C#>>正文


C# ImapEngine.ParseMessage方法代码示例

本文整理汇总了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;
开发者ID:repne,项目名称:MailKit,代码行数:67,代码来源:ImapFolder.cs


注:本文中的MailKit.Net.Imap.ImapEngine.ParseMessage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。