コード例 #1
0
        void OnFieldsChanged(object sender, HeaderListChangedEventArgs e)
        {
            var stream  = new MemoryBlockStream();
            var options = FormatOptions.Default;

            fields.WriteTo(options, stream);
            stream.Position = 0;

            ContentObject = new ContentObject(stream);
        }
コード例 #2
0
		void OnFieldsChanged (object sender, HeaderListChangedEventArgs e)
		{
			var options = FormatOptions.GetDefault ();
			var stream = new MemoryBlockStream ();

			fields.WriteTo (options, stream);
			stream.Write (options.NewLineBytes, 0, options.NewLineBytes.Length);
			stream.Position = 0;

			ContentObject = new ContentObject (stream);
		}
コード例 #3
0
        void OnFieldsChanged(object sender, HeaderListChangedEventArgs e)
        {
            var options = FormatOptions.GetDefault();
            var stream  = new MemoryBlockStream();

            fields.WriteTo(options, stream);
            stream.Write(options.NewLineBytes, 0, options.NewLineBytes.Length);
            stream.Position = 0;

            ContentObject = new ContentObject(stream);
        }
コード例 #4
0
ファイル: MimeMessage.cs プロジェクト: yukine/MimeKit
		void HeadersChanged (object o, HeaderListChangedEventArgs e)
		{
			InternetAddressList list;
			InternetAddress address;
			byte[] rawValue;
			int index = 0;

			switch (e.Action) {
			case HeaderListChangedAction.Added:
				if (addresses.TryGetValue (e.Header.Field, out list)) {
					AddAddresses (e.Header, list);
					break;
				}

				rawValue = e.Header.RawValue;

				switch (e.Header.Id) {
				case HeaderId.MimeVersion:
					MimeUtils.TryParse (rawValue, 0, rawValue.Length, out version);
					break;
				case HeaderId.References:
					references.Changed -= ReferencesChanged;
					foreach (var msgid in MimeUtils.EnumerateReferences (rawValue, 0, rawValue.Length))
						references.Add (msgid);
					references.Changed += ReferencesChanged;
					break;
				case HeaderId.InReplyTo:
					inreplyto = MimeUtils.EnumerateReferences (rawValue, 0, rawValue.Length).FirstOrDefault ();
					break;
				case HeaderId.ResentMessageId:
					resentMessageId = MimeUtils.EnumerateReferences (rawValue, 0, rawValue.Length).FirstOrDefault ();
					break;
				case HeaderId.MessageId:
					messageId = MimeUtils.EnumerateReferences (rawValue, 0, rawValue.Length).FirstOrDefault ();
					break;
				case HeaderId.ResentSender:
					if (InternetAddress.TryParse (Headers.Options, rawValue, ref index, rawValue.Length, false, out address))
						resentSender = address as MailboxAddress;
					break;
				case HeaderId.Sender:
					if (InternetAddress.TryParse (Headers.Options, rawValue, ref index, rawValue.Length, false, out address))
						sender = address as MailboxAddress;
					break;
				case HeaderId.ResentDate:
					DateUtils.TryParse (rawValue, 0, rawValue.Length, out resentDate);
					break;
				case HeaderId.Importance:
					switch (e.Header.Value.ToLowerInvariant ().Trim ()) {
					case "high": importance = MessageImportance.High; break;
					case "low": importance = MessageImportance.Low; break;
					default: importance = MessageImportance.Normal; break;
					}
					break;
				case HeaderId.Priority:
					switch (e.Header.Value.ToLowerInvariant ().Trim ()) {
					case "non-urgent": priority = MessagePriority.NonUrgent; break;
					case "urgent": priority = MessagePriority.Urgent; break;
					default: priority = MessagePriority.Normal; break;
					}
					break;
				case HeaderId.Date:
					DateUtils.TryParse (rawValue, 0, rawValue.Length, out date);
					break;
				}
				break;
			case HeaderListChangedAction.Changed:
			case HeaderListChangedAction.Removed:
				if (addresses.TryGetValue (e.Header.Field, out list)) {
					ReloadAddressList (e.Header.Id, list);
					break;
				}

				ReloadHeader (e.Header.Id);
				break;
			case HeaderListChangedAction.Cleared:
				foreach (var kvp in addresses) {
					kvp.Value.Changed -= InternetAddressListChanged;
					kvp.Value.Clear ();
					kvp.Value.Changed += InternetAddressListChanged;
				}

				references.Changed -= ReferencesChanged;
				references.Clear ();
				references.Changed += ReferencesChanged;

				importance = MessageImportance.Normal;
				priority = MessagePriority.Normal;
				resentMessageId = null;
				resentSender = null;
				inreplyto = null;
				messageId = null;
				version = null;
				sender = null;
				break;
			default:
				throw new ArgumentOutOfRangeException ();
			}
		}
コード例 #5
0
ファイル: MimeEntity.cs プロジェクト: tfreitasleal/MimeKit
 void HeadersChanged(object sender, HeaderListChangedEventArgs e)
 {
     OnHeadersChanged(e.Action, e.Header);
 }
コード例 #6
0
ファイル: MimeEntity.cs プロジェクト: gphummer/MimeKit
		void HeadersChanged (object sender, HeaderListChangedEventArgs e)
		{
			OnHeadersChanged (e.Action, e.Header);
		}
コード例 #7
0
 void OnGroupChanged(object sender, HeaderListChangedEventArgs e)
 {
     OnChanged();
 }
コード例 #8
0
		void OnFieldsChanged (object sender, HeaderListChangedEventArgs e)
		{
			var stream = new MemoryBlockStream ();
			var options = FormatOptions.Default;

			fields.WriteTo (options, stream);
			stream.Position = 0;

			ContentObject = new ContentObject (stream);
		}
コード例 #9
0
ファイル: MimeMessage.cs プロジェクト: princeoffoods/MimeKit
        void HeadersChanged(object sender, HeaderListChangedEventArgs e)
        {
            InternetAddressList list;

            switch (e.Action) {
            case HeaderListChangedAction.Added:
                if (addresses.TryGetValue (e.Header.Field, out list)) {
                    AddAddresses (e.Header, list);
                    break;
                }

                switch (e.Header.Id) {
                case HeaderId.MimeVersion:
                    MimeUtils.TryParseVersion (e.Header.RawValue, 0, e.Header.RawValue.Length, out version);
                    break;
                case HeaderId.References:
                    references.Changed -= ReferencesChanged;
                    foreach (var msgid in MimeUtils.EnumerateReferences (e.Header.RawValue, 0, e.Header.RawValue.Length))
                        references.Add (msgid);
                    references.Changed += ReferencesChanged;
                    break;
                case HeaderId.InReplyTo:
                    inreplyto = MimeUtils.EnumerateReferences (e.Header.RawValue, 0, e.Header.RawValue.Length).FirstOrDefault ();
                    break;
                case HeaderId.MessageId:
                    messageId = MimeUtils.EnumerateReferences (e.Header.RawValue, 0, e.Header.RawValue.Length).FirstOrDefault ();
                    break;
                case HeaderId.Date:
                    DateUtils.TryParseDateTime (e.Header.RawValue, 0, e.Header.RawValue.Length, out date);
                    break;
                }
                break;
            case HeaderListChangedAction.Changed:
            case HeaderListChangedAction.Removed:
                if (addresses.TryGetValue (e.Header.Field, out list)) {
                    ReloadAddressList (e.Header.Field, list);
                    break;
                }

                ReloadHeader (e.Header.Id, e.Header.Field);
                break;
            case HeaderListChangedAction.Cleared:
                foreach (var kvp in addresses) {
                    kvp.Value.Changed -= InternetAddressListChanged;
                    kvp.Value.Clear ();
                    kvp.Value.Changed += InternetAddressListChanged;
                }

                references.Changed -= ReferencesChanged;
                references.Clear ();
                references.Changed += ReferencesChanged;

                inreplyto = null;
                messageId = null;
                version = null;
                break;
            default:
                throw new ArgumentOutOfRangeException ();
            }
        }
コード例 #10
0
ファイル: MimeMessage.cs プロジェクト: sscctech/MimeKit
        void HeadersChanged(object sender, HeaderListChangedEventArgs e)
        {
            InternetAddressList list;

            switch (e.Action)
            {
            case HeaderListChangedAction.Added:
                if (addresses.TryGetValue(e.Header.Field, out list))
                {
                    AddAddresses(e.Header, list);
                    break;
                }

                switch (e.Header.Id)
                {
                case HeaderId.MimeVersion:
                    MimeUtils.TryParseVersion(e.Header.RawValue, 0, e.Header.RawValue.Length, out version);
                    break;

                case HeaderId.References:
                    references.Changed -= ReferencesChanged;
                    foreach (var msgid in MimeUtils.EnumerateReferences(e.Header.RawValue, 0, e.Header.RawValue.Length))
                    {
                        references.Add(msgid);
                    }
                    references.Changed += ReferencesChanged;
                    break;

                case HeaderId.InReplyTo:
                    inreplyto = MimeUtils.EnumerateReferences(e.Header.RawValue, 0, e.Header.RawValue.Length).FirstOrDefault();
                    break;

                case HeaderId.MessageId:
                    messageId = MimeUtils.EnumerateReferences(e.Header.RawValue, 0, e.Header.RawValue.Length).FirstOrDefault();
                    break;

                case HeaderId.Date:
                    DateUtils.TryParseDateTime(e.Header.RawValue, 0, e.Header.RawValue.Length, out date);
                    break;
                }
                break;

            case HeaderListChangedAction.Changed:
            case HeaderListChangedAction.Removed:
                if (addresses.TryGetValue(e.Header.Field, out list))
                {
                    ReloadAddressList(e.Header.Field, list);
                    break;
                }

                ReloadHeader(e.Header.Id, e.Header.Field);
                break;

            case HeaderListChangedAction.Cleared:
                foreach (var kvp in addresses)
                {
                    kvp.Value.Changed -= InternetAddressListChanged;
                    kvp.Value.Clear();
                    kvp.Value.Changed += InternetAddressListChanged;
                }

                references.Changed -= ReferencesChanged;
                references.Clear();
                references.Changed += ReferencesChanged;

                inreplyto = null;
                messageId = null;
                version   = null;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }