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


C# Message.AddAttachmentFromString方法代码示例

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


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

示例1: RetrieveMessageObject

        /// <summary>
        /// Retrieves the message at the given index.
        /// </summary>
        /// <param name="message_index">The index of the message to be retrieved.</param>
        /// <returns>A Message object representing the message.</returns>
        /// <example>
        /// <code>
        /// C#
        /// 
        /// Pop3Client pop = new Pop3Client();
        /// pop.Connect("mail.myhost.com","user","pass");
        /// Message message = pop.RetrieveMessageObject(1);
        /// pop.Disconnect();
        /// 
        /// VB.NET
        /// 
        /// Dim pop As New Pop3Client
        /// pop.Connect("mail.myhost.com","user","pass")
        /// Dim message as Message = pop.RetrieveMessageObject(1)
        /// pop.Disconnect()
        /// 
        /// JScript.NET
        /// 
        /// var pop:Pop3Client = new Pop3Client();
        /// pop.Connect("mail.myhost.com","user","pass");
        /// var message:Message = pop.RetrieveMessageObject(1);
        /// pop.Disconnect();
        /// </code>
        /// </example>
        public Message RetrieveMessageObject(int message_index)
        {
            var msg = RetrieveMessageString(message_index);

            Message message;

            try
            {
                message = Parser.ParseMessage(ref msg);
            }
            catch (Exception ex)
            {
                if (ex is ParsingException || ex is IndexOutOfRangeException)
                {
                    var header_string = RetrieveHeaderString(message_index);

                    Header header;

                    if (!Parser.TryParseDefectiveHeader(header_string, out header))
                        throw;

                    message = new Message(header);

                    message.AddAttachmentFromString("original_message.eml", msg);

                    message.OriginalData = Encoding.GetEncoding("iso-8859-1").GetBytes(msg);

                    message.HasParseError = true;
                }
                else
                    throw;
            }

            return message;
        }
开发者ID:vipwan,项目名称:CommunityServer,代码行数:64,代码来源:Pop3Client.cs

示例2: GetPop3MessageAfterParseError

        private Message GetPop3MessageAfterParseError(Pop3Client client, int message_index)
        {
            var header = client.RetrieveHeaderObject(message_index);

            var eml_message_string = client.RetrieveMessageString(message_index);

            var message = new Message(header);

            message.AddAttachmentFromString("original_message.eml", eml_message_string);

            return message;
        }
开发者ID:haoasqui,项目名称:ONLYOFFICE-Server,代码行数:12,代码来源:MailQueueItem.cs

示例3: ParseMessage

        /// <summary>
        /// Parses a Message from a string formatted accordingly to the RFC822.
        /// </summary>
        /// <param name="msg">The string containing the message data to be parsed.</param>
        /// <returns>The parsed message as a Message object.</returns>
        /// <example>
        /// <code>
        /// C#
        /// 
        /// Message message = Parser.ParseMessageString(rfc822string);
        /// //Expose the subject
        /// string subject = message.Subject;
        /// 
        /// VB.NET
        /// 
        /// Dim message As Message = Parser.ParseMessageString(rfc822string)
        /// 'Expose the subject
        /// Dim subject As String = message.Subject
        /// 
        /// JScript.NET
        /// 
        /// var message:Message = Parser.ParseMessageString(rfc822string);
        /// //Expose the subject
        /// var subject:string = message.Subject;
        /// </code>
        /// </example>
        public static Message ParseMessage(ref string msg)
        {
            var message = new Message();

            try
            {
                // Build a part tree and get all headers. 
                var part = ParseMimePart(ref msg, message);
                // Fill a new message object with the new information.
                //message.OriginalData = data;
                message.HeaderFields = part.HeaderFields;
                message.HeaderFieldNames = part.HeaderFieldNames;

                // Dispatch header fields to corresponding object.
                foreach (var key in message.HeaderFields.AllKeys)
                {
                    var name = key;
                    var value = message.HeaderFields[key];
                    // TODO : Fix trace
                    if (name.Equals("received")) message.Trace.Add(ParseTrace(key + ": " + value));
                    else if (name.Equals("to")) message.To = ParseAddresses(value);
                    else if (name.Equals("cc")) message.Cc = ParseAddresses(value);
                    else if (name.Equals("bcc")) message.Bcc = ParseAddresses(value);
                    else if (name.Equals("reply-to")) message.ReplyTo = ParseAddress(value);
                    else if (name.Equals("from")) message.From = ParseAddress(value);
                    else if (name.Equals("sender")) message.Sender = ParseAddress(value);
                    else if (name.Equals("content-type")) message.ContentType = GetContentType(key + ": " + value);
                    else if (name.Equals("content-disposition"))
                        message.ContentDisposition = GetContentDisposition(key + ": " + value);
                    else if (name.Equals("domainkey-signature"))
                        message.Signatures.DomainKeys = Signature.Parse(key + ": " + value, message);
                }

                if (message.ContentType.MimeType.Equals("application/pkcs7-mime")
                    || message.ContentType.MimeType.Equals("application/x-pkcs7-mime"))
                {
                    if (message.ContentType.Parameters["smime-type"] != null
                        && message.ContentType.Parameters["smime-type"].Equals("enveloped-data"))
                    {
                        message.IsSmimeEncrypted = true;
                    }

                    if (message.ContentType.Parameters["smime-type"] != null
                        && message.ContentType.Parameters["smime-type"].Equals("signed-data"))
                    {
                        message.HasSmimeSignature = true;
                    }
                }

                if (message.ContentType.MimeType.Equals("multipart/signed"))
                {
                    message.HasSmimeDetachedSignature = true;
                }

                if (message.ContentType.MimeType.Equals("multipart/report"))
                {
                    message.IsMultipartReport = true;
                }

                // Keep a reference to the part tree within the new Message object.
                message.PartTreeRoot = part;
                // Dispatch the part tree content to the appropriate collections and properties.
                DispatchParts(ref message);

                // Check message for text limit
                const int message_limit = 500000; // 500kb

                if (!string.IsNullOrEmpty(message.BodyHtml.Text))
                {
                    if (message.BodyHtml.Text.Length > message_limit)
                    {
                        var charset = (!string.IsNullOrEmpty(message.BodyHtml.Charset) ? message.BodyHtml.Charset : "iso-8859-1");

                        message.AddAttachmentFromString("original_message.html",
//.........这里部分代码省略.........
开发者ID:vipwan,项目名称:CommunityServer,代码行数:101,代码来源:Parser.cs

示例4: GetImapMessageAfterParseError

        private Message GetImapMessageAfterParseError(Mailbox mb, int uid)
        {
            var header = GetImapHeader(mb, uid);

            var message = new Message(header);

            var eml_message_string = mb.Fetch.UidMessageString(uid);

            message.AddAttachmentFromString("original_message.eml", eml_message_string);

            return message;
        }
开发者ID:haoasqui,项目名称:ONLYOFFICE-Server,代码行数:12,代码来源:MailQueueItem.Imap.cs


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