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


C# MailMessage.ThrowIfNull方法代码示例

本文整理汇总了C#中System.Net.Mail.MailMessage.ThrowIfNull方法的典型用法代码示例。如果您正苦于以下问题:C# MailMessage.ThrowIfNull方法的具体用法?C# MailMessage.ThrowIfNull怎么用?C# MailMessage.ThrowIfNull使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Net.Mail.MailMessage的用法示例。


在下文中一共展示了MailMessage.ThrowIfNull方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: StoreMessage

		/// <summary>
		/// Stores the specified mail message on the IMAP server.
		/// </summary>
		/// <param name="message">The mail message to store on the server.</param>
		/// <param name="seen">Set this to true to set the \Seen flag for the message on the
		/// server.</param>
		/// <param name="mailbox">The mailbox the message will be stored in. If this parameter is
		/// omitted, the value of the DefaultMailbox property is used to determine the mailbox to store
		/// the message in.</param>
		/// <returns>The unique identifier (UID) of the stored message.</returns>
		/// <exception cref="ArgumentNullException">The message parameter is null.</exception>
		/// <exception cref="BadServerResponseException">The mail message could not be stored. The
		/// message property of the exception contains the error message returned by the
		/// server.</exception>
		/// <exception cref="ObjectDisposedException">The ImapClient object has been disposed.</exception>
		/// <exception cref="IOException">There was a failure writing to or reading from the
		/// network.</exception>
		/// <exception cref="NotAuthenticatedException">The method was called in non-authenticated
		/// state, i.e. before logging in.</exception>
		/// <remarks>A unique identifier (UID) is a 32-bit value assigned to each message which uniquely
		/// identifies the message within the respective mailbox. No two messages in a mailbox share
		/// the same UID.</remarks>
		/// <seealso cref="StoreMessages"/>
		/// <include file='Examples.xml' path='S22/Imap/ImapClient[@name="StoreMessage"]/*'/>
		public uint StoreMessage(MailMessage message, bool seen = false, string mailbox = null) {
			AssertValid();
			message.ThrowIfNull("message");
			string mime822 = message.ToMIME822();
			lock (sequenceLock) {
				PauseIdling();
				if (mailbox == null)
					mailbox = defaultMailbox;
				string tag = GetTag();
				string response = SendCommandGetResponse(tag + "APPEND " +
					Util.UTF7Encode(mailbox).QuoteString() + (seen ? @" (\Seen)" : "") +
					" {" + mime822.Length + "}");
				// The server must send a continuation response before we can go ahead with the actual
				// message data.
				if (!response.StartsWith("+"))
					throw new BadServerResponseException(response);
				response = SendCommandGetResponse(mime822);
				while (response.StartsWith("*"))
					response = GetResponse(); 
				ResumeIdling();
				if (!IsResponseOK(response, tag))
					throw new BadServerResponseException(response);
				return GetHighestUID(mailbox);
			}
		}
开发者ID:bebo1984,项目名称:S22.Imap,代码行数:49,代码来源:ImapClient.cs

示例2: StoreMessage

        public uint StoreMessage(MailMessage message, bool seen = false, string mailbox = null)
        {
            AssertValid();
            message.ThrowIfNull("message");
            string mime822 = message.ToMIME822();
            lock (sequenceLock)
            {
                PauseIdling();
                if (mailbox == null)
                {
                    mailbox = defaultMailbox;
                }

                string resptag = GetTag();
                string response = SendCommandGetResponse(resptag + "APPEND " +
                    Util.UTF7Encode(mailbox).QuoteString() + (seen ? @" (\Seen)" : string.Empty) +
                    " {" + mime822.Length + "}");

                if (!response.StartsWith("+"))
                {
                    throw new BadServerResponseException(response);
                }

                response = SendCommandGetResponse(mime822);
                while (response.StartsWith("*"))
                {
                    response = GetResponse();
                }

                ResumeIdling();
                if (!IsResponseOK(response, resptag))
                {
                    throw new BadServerResponseException(response);
                }

                return GetHighestUid(mailbox);
            }
        }
开发者ID:BoyarinO,项目名称:EmailClient,代码行数:38,代码来源:ImapClient.cs


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