A message envelope containing a brief summary of the message.
The envelope of a message contains information such as the date the message was sent, the subject of the message, the sender of the message, who the message was sent to, which message(s) the message may be in reply to, and the message id.
Ejemplo n.º 1
0
        public void TestNotification()
        {
            var testSummary = new MessageSummary(0);
            var env = new Envelope();
            env.Subject = "testNotificationSubject";
            env.From.Add(new MailboxAddress("testNotificationName", "TestNotificationAddress"));
            env.MessageId = "123TestAbc";
            env.Date = DateTime.Now;
            testSummary.Envelope = env;

            Notify(testSummary, NotificationType.Received, "testNotification");
        }
Ejemplo n.º 2
0
		public void TestSerialization ()
		{
			var original = new Envelope ();
			original.Bcc.Add (new MailboxAddress ("Bcc Recipient", "*****@*****.**"));
			original.Cc.Add (new MailboxAddress ("Routed Mailbox", new string[] { "domain.org" }, "*****@*****.**"));
			original.Date = DateTimeOffset.Now;
			original.From.Add (new MailboxAddress ("MailKit Unit Tests", "*****@*****.**"));
			original.InReplyTo = "<*****@*****.**>";
			original.MessageId = "<*****@*****.**>";
			original.ReplyTo.Add (new MailboxAddress ("Reply-To", "*****@*****.**"));
			original.Sender.Add (new MailboxAddress ("The Real Sender", "*****@*****.**"));
			original.Subject = "This is the subject";
			original.To.Add (new GroupAddress ("Group Address", new MailboxAddress[] {
				new MailboxAddress ("Recipient 1", "*****@*****.**"),
				new MailboxAddress ("Recipient 2", "*****@*****.**")
			}));
			var text = original.ToString ();
			Envelope envelope;

			Assert.IsTrue (Envelope.TryParse (text, out envelope));
			var text2 = envelope.ToString ();

			Assert.AreEqual (text, text2);
		}
Ejemplo n.º 3
0
		/// <summary>
		/// Tries to parse the given text into a new <see cref="MailKit.Envelope"/> instance.
		/// </summary>
		/// <remarks>
		/// <para>Parses an Envelope value from the specified text.</para>
		/// <note type="warning">This syntax, while similar to IMAP's ENVELOPE syntax, is not
		/// completely compatible.</note>
		/// </remarks>
		/// <returns><c>true</c>, if the envelope was successfully parsed, <c>false</c> otherwise.</returns>
		/// <param name="text">The text to parse.</param>
		/// <param name="envelope">The parsed envelope.</param>
		/// <exception cref="System.ArgumentNullException">
		/// <paramref name="text"/> is <c>null</c>.
		/// </exception>
		public static bool TryParse (string text, out Envelope envelope)
		{
			if (text == null)
				throw new ArgumentNullException (nameof (text));

			int index = 0;

			return TryParse (text, ref index, out envelope) && index == text.Length;
		}
Ejemplo n.º 4
0
		internal static bool TryParse (string text, ref int index, out Envelope envelope)
		{
			InternetAddressList from, sender, replyto, to, cc, bcc;
			string inreplyto, messageid, subject, nstring;
			DateTimeOffset? date = null;

			envelope = null;

			while (index < text.Length && text[index] == ' ')
				index++;

			if (index >= text.Length || text[index] != '(') {
				if (index + 3 <= text.Length && text.Substring (index, 3) == "NIL") {
					index += 3;
					return true;
				}

				return false;
			}

			index++;

			if (!TryParse (text, ref index, out nstring))
				return false;

			if (nstring != null) {
				DateTimeOffset value;

				if (!DateUtils.TryParse (nstring, out value))
					return false;

				date = value;
			}

			if (!TryParse (text, ref index, out subject))
				return false;

			if (!TryParse (text, ref index, out from))
				return false;

			if (!TryParse (text, ref index, out sender))
				return false;

			if (!TryParse (text, ref index, out replyto))
				return false;

			if (!TryParse (text, ref index, out to))
				return false;

			if (!TryParse (text, ref index, out cc))
				return false;

			if (!TryParse (text, ref index, out bcc))
				return false;

			if (!TryParse (text, ref index, out inreplyto))
				return false;

			if (!TryParse (text, ref index, out messageid))
				return false;

			if (index >= text.Length || text[index] != ')')
				return false;

			index++;

			envelope = new Envelope {
				Date = date,
				Subject = subject,
				From = from,
				Sender = sender,
				ReplyTo = replyto,
				To = to,
				Cc = cc,
				Bcc = bcc,
				InReplyTo = inreplyto != null ? MimeUtils.EnumerateReferences (inreplyto).FirstOrDefault () ?? inreplyto : null,
				MessageId = messageid != null ? MimeUtils.EnumerateReferences (messageid).FirstOrDefault () ?? messageid : null
			};

			return true;
		}
Ejemplo n.º 5
0
		internal static void Encode (StringBuilder builder, Envelope envelope)
		{
			if (envelope == null) {
				builder.Append ("NIL");
				return;
			}

			envelope.Encode (builder);
		}
Ejemplo n.º 6
0
        private void intialize() {

            if (Properties.Settings.Default.firstUse) {
                pb1.Visibility = Visibility.Visible;
                bt1.IsEnabled = false;
                folder.IsEnabled = false;
                exRefresh();
            }
            else {
                int i = 0;
                try {
                    for (long x = 0; x <= (long)Properties.Settings.Default[lastUid]; x++) {
                        if (File.Exists("D:\\emails\\" + mailboxName + "\\" + x + ".eml")) {
                            Envelope m = new Envelope(); string temp;
                            temp = new StreamReader("D:\\emails\\" + mailboxName + "\\" + x + ".eml").ReadToEnd();
                            Envelope.TryParse(temp, out m);
                            Dispatcher.Invoke(() => dataGrid.Items.Add(new { Col1 = i + 1, Col2 = String.Format("{0:yyyy/MM/dd HH:mm:ss}", m.Date.Value.LocalDateTime).ToString(), Col3 = m.From.ToString().Replace('"', ' '), Col4 = m.Subject, Col5 = temp.Split('\n')[1] }));
                            i++;
                        }
                    }
                }
                catch (Exception e) {
                    MessageBox.Show(e.ToString());
                }
            }
        }