internal static ImapDataResponse Create(ImapData[] data) { if (2 <= data.Length && data[1].Format == ImapDataFormat.Text && ImapDataResponseType.SizeStatusTypes.Has(data[1].GetTextAsString())) { // 'Mailbox Size' or 'Message Status' var dataWithoutType = new ImapData[data.Length - 1]; dataWithoutType[0] = data[0]; Array.Copy(data, 2, dataWithoutType, 1, dataWithoutType.Length - 1); return new ImapDataResponse(ImapDataResponseType.SizeStatusTypes.Find(data[1].GetTextAsString()), dataWithoutType); } else if (1 <= data.Length && data[0].Format == ImapDataFormat.Text && ImapDataResponseType.AllTypes.Has(data[0].GetTextAsString())) { return new ImapDataResponse(ImapDataResponseType.AllTypes.Find(data[0].GetTextAsString()), (1 == data.Length) ? new ImapData[] {} : data.Slice(1)); } else { Smdn.Net.Imap4.Client.Trace.Verbose("unknown data response type: {0}", data[0]); return new ImapDataResponse(ImapDataResponseType.InvalidOrUnknown, data); } }
public Account(string userName, string email, string password, ImapData imapData, SmtpData smtpData) { UserName = userName; Email = email; Password = password; ImapData = imapData; SmtpData = smtpData; }
public void TestMethod1() { string input = "* 10 FETCH (FLAGS () INTERNALDATE \"30-Nov-2017 16:14:34 +0000\" RFC822.SIZE 61631 ENVELOPE (\"Thu, 30 Nov 2017 15:41:49 +0000\" \"You have a new message\" ((\"[email protected]\" NIL \"donotreply\" \"email01.aaaaaaaaaa.co.uk\")) NIL ((\"AAAAAA BBBB\" NIL \"info\" \"email01.aaaaaaaaaa.co.uk\")) ((NIL NIL \"mmmmm\" \"hotmail.com\")) NIL NIL NIL \"<[email protected]\\\" <*****@*****.**>\") BODYSTRUCTURE(\"text\" \"html\" (\"charset\" \"UTF-8\") NIL NIL \"quoted-printable\" 21833 574 NIL NIL NIL NIL) UID 1083)"; var data = Encoding.UTF8.GetBytes(input); List <byte[]> tokens = new List <byte[]>(); ImapData.SplitTokens(data, tokens); Assert.AreEqual(4, tokens.Count); var subTokens = ImapData.SplitToken(tokens[3]); Assert.AreEqual(11, subTokens.Count); var envItems = ImapData.SplitToken(Encoding.UTF8.GetString(subTokens[7])); Assert.AreEqual(10, envItems.Length); string dateStr = ImapData.StripQuotes(envItems[0], true); string subject = ImapData.StripQuotes(envItems[1], false); string[] from = ImapData.SplitToken(envItems[2]); string[] sender = ImapData.SplitToken(envItems[3]); string[] replyTo = ImapData.SplitToken(envItems[4]); string[] to = ImapData.SplitToken(envItems[5]); string[] cc = ImapData.SplitToken(envItems[6]); string[] bcc = ImapData.SplitToken(envItems[7]); string inReplyTo = ImapData.StripQuotes(envItems[8], false); string msgId = ImapData.StripQuotes(envItems[9], false); var date = ImapData.ParseDate(dateStr); Assert.AreEqual(11, date.Month); Assert.AreEqual(2017, date.Year); Assert.AreEqual(30, date.Day); Assert.AreEqual("You have a new message", subject); Assert.AreEqual(1, from.Length); Assert.IsNull(sender); Assert.AreEqual(1, replyTo.Length); Assert.AreEqual(1, to.Length); Assert.IsNull(cc); Assert.IsNull(bcc); Assert.AreEqual(0, inReplyTo.Length); Assert.AreEqual("<[email protected]\" <*****@*****.**>", msgId); }
private ImapDataResponse(ImapDataResponseType type, ImapData[] data) { this.Type = type; this.Data = data; }