本文整理汇总了C#中IMAPSimulator.SelectFolder方法的典型用法代码示例。如果您正苦于以下问题:C# IMAPSimulator.SelectFolder方法的具体用法?C# IMAPSimulator.SelectFolder怎么用?C# IMAPSimulator.SelectFolder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMAPSimulator
的用法示例。
在下文中一共展示了IMAPSimulator.SelectFolder方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestDateSortOrderNonexistantDate
public void TestDateSortOrderNonexistantDate()
{
hMailServer.Account oAccount = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "[email protected]", "test");
IMAPSimulator oSimulator = new IMAPSimulator();
string sWelcomeMessage = oSimulator.Connect();
oSimulator.LogonWithLiteral("[email protected]", "test");
Assert.IsTrue(oSimulator.SelectFolder("Inbox"));
string response = oSimulator.SendSingleCommandWithLiteral("A04 APPEND INBOX \"22-Feb-2008 22:00:00 +0200\" {4}", "ABCD");
Assert.IsTrue(response.Contains("* 1 EXISTS"), response);
response = oSimulator.SendSingleCommandWithLiteral("A04 APPEND INBOX \"22-Feb-2008 21:00:00 +0200\" {4}", "ABCD");
Assert.IsTrue(response.Contains("* 2 EXISTS"), response);
response = oSimulator.SendSingleCommandWithLiteral("A04 APPEND INBOX \"22-Feb-2008 20:00:00 +0200\" {4}", "ABCD");
Assert.IsTrue(response.Contains("* 3 EXISTS"), response);
response = oSimulator.SendSingleCommandWithLiteral("A04 APPEND INBOX \"23-Feb-2008 01:30:23 +0200\" {4}", "ABCD");
Assert.IsTrue(response.Contains("* 4 EXISTS"), response);
/*
* RFC 5256 "2.2. Sent Date" chapter. If the sent date cannot be determined (a Date: header is missing or cannot be parsed),
* the INTERNALDATE for that message is used as the sent date.
*/
string sortDateResponse = oSimulator.SendSingleCommand("A10 SORT (DATE) US-ASCII ALL");
string sortArivalDateResponse = oSimulator.SendSingleCommand("A10 SORT (ARRIVAL) US-ASCII ALL");
Assert.IsTrue(sortArivalDateResponse.Contains(" 3 2 1 4"));
Assert.AreEqual(sortDateResponse, sortArivalDateResponse);
oSimulator.Disconnect();
}
示例2: FolderMarkedAsReadOnlyWhenUserHasReadOnlyRights
public void FolderMarkedAsReadOnlyWhenUserHasReadOnlyRights()
{
hMailServer.Application application = SingletonProvider<Utilities>.Instance.GetApp();
hMailServer.Account account1 = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "[email protected]", "test");
hMailServer.IMAPFolders publicFolders = _settings.PublicFolders;
hMailServer.IMAPFolder folder = publicFolders.Add("Share1");
folder.Save();
hMailServer.IMAPFolderPermission permission = folder.Permissions.Add();
permission.PermissionAccountID = account1.ID;
permission.PermissionType = hMailServer.eACLPermissionType.ePermissionTypeUser;
permission.set_Permission(hMailServer.eACLPermission.ePermissionLookup, true);
permission.set_Permission(hMailServer.eACLPermission.ePermissionRead, true);
permission.Save();
string selectResult = string.Empty;
IMAPSimulator oSimulator1 = new IMAPSimulator();
oSimulator1.Connect();
oSimulator1.LogonWithLiteral(account1.Address, "test");
oSimulator1.SelectFolder("#Public.Share1", out selectResult);
oSimulator1.Disconnect();
Assert.IsTrue(selectResult.Contains("[READ-ONLY]"), selectResult);
Assert.IsFalse(selectResult.Contains("[READ-WRITE]"), selectResult);
}
示例3: TestDateSortOrder
public void TestDateSortOrder()
{
hMailServer.Account oAccount = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "[email protected]", "test");
IMAPSimulator oSimulator = new IMAPSimulator();
string sWelcomeMessage = oSimulator.Connect();
oSimulator.LogonWithLiteral("[email protected]", "test");
Assert.IsTrue(oSimulator.SelectFolder("Inbox"));
string response = oSimulator.SendSingleCommandWithLiteral("A04 APPEND INBOX \"22-Feb-2008 22:00:00 +0200\" {37}", "Date: Wed, 15 Dec 2010 13:00:00 +0000");
Assert.IsTrue(response.Contains("* 1 EXISTS"), response);
response = oSimulator.SendSingleCommandWithLiteral("A04 APPEND INBOX \"22-Feb-2008 21:00:00 +0200\" {37}", "Date: Wed, 15 Dec 2010 14:00:00 +0000");
Assert.IsTrue(response.Contains("* 2 EXISTS"), response);
response = oSimulator.SendSingleCommandWithLiteral("A04 APPEND INBOX \"22-Feb-2008 20:00:00 +0200\" {37}", "Date: Wed, 15 Dec 2010 12:00:00 +0000");
Assert.IsTrue(response.Contains("* 3 EXISTS"), response);
response = oSimulator.SendSingleCommandWithLiteral("A04 APPEND INBOX \"23-Feb-2008 01:30:23 +0200\" {37}", "Date: Wed, 15 Dec 2010 11:00:00 +0000");
Assert.IsTrue(response.Contains("* 4 EXISTS"), response);
string sortDateResponse = oSimulator.SendSingleCommand("A10 SORT (DATE) US-ASCII ALL");
Assert.IsTrue(sortDateResponse.Contains(" 4 3 1 2"));
oSimulator.Disconnect();
}
示例4: TestNestedOrSearch
public void TestNestedOrSearch()
{
hMailServer.Application application = SingletonProvider<Utilities>.Instance.GetApp();
;
hMailServer.Account oAccount = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "[email protected]", "test");
// Send a message to this account.
SMTPClientSimulator oSMTP = new SMTPClientSimulator();
oSMTP.Send("[email protected]", "[email protected]", "Search test", "This is a test of IMAP Search");
IMAPSimulator.AssertMessageCount(oAccount.Address, "test", "Inbox", 1);
IMAPSimulator oSimulator = new IMAPSimulator();
string sWelcomeMessage = oSimulator.Connect();
oSimulator.Logon("[email protected]", "test");
oSimulator.SelectFolder("INBOX");
string result = oSimulator.SendSingleCommand("A4 SEARCH ALL OR OR SINCE 28-May-2008 SINCE 28-May-2008 SINCE 28-May-2008");
Assert.IsTrue(result.StartsWith("* SEARCH 1"), result);
result = oSimulator.SendSingleCommand("A4 SEARCH ALL OR SMALLER 1 LARGER 10000");
Assert.IsTrue(result.StartsWith("* SEARCH\r\n"), result);
result = oSimulator.SendSingleCommand("A4 SEARCH ALL OR OR SMALLER 1 LARGER 10000 SMALLER 10000");
Assert.IsTrue(result.StartsWith("* SEARCH 1\r\n"), result);
}
示例5: TestCreateFolderWithSlash
public void TestCreateFolderWithSlash()
{
hMailServer.Account oAccount = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "[email protected]", "test");
string folderName = "ABC\\123";
IMAPSimulator oSimulator = new IMAPSimulator();
string sWelcomeMessage = oSimulator.Connect();
oSimulator.Logon(oAccount.Address, "test");
Assert.IsTrue(oSimulator.CreateFolder(folderName));
Assert.IsTrue(oSimulator.List().Contains(folderName));
Assert.IsTrue(oSimulator.SelectFolder(folderName));
oSimulator.Disconnect();
}
示例6: TestAppendFolderNameInOctet
public void TestAppendFolderNameInOctet()
{
hMailServer.Account oAccount = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "[email protected]", "test");
IMAPSimulator oSimulator = new IMAPSimulator();
string sWelcomeMessage = oSimulator.Connect();
oSimulator.Logon("[email protected]", "test");
oSimulator.SelectFolder("INBOX");
oSimulator.CreateFolder("MONK");
oSimulator.SendRaw("A01 APPEND {4}\r\n");
string result = oSimulator.Receive();
Assert.IsTrue(result.StartsWith("+ Ready for additional command text."));
oSimulator.SendRaw("MONK (\\Seen) \"20-Jan-2009 12:59:50 +0100\" {5}\r\n");
result = oSimulator.Receive();
Assert.IsTrue(result.StartsWith("+ Ready for literal data"));
oSimulator.SendRaw("WOOOT\r\n");
result = oSimulator.Receive();
Assert.AreEqual("A01 OK APPEND completed\r\n", result);
}
示例7: TestSearchUID
public void TestSearchUID()
{
hMailServer.Application application = SingletonProvider<Utilities>.Instance.GetApp();
;
hMailServer.Account account = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "[email protected]", "test");
// Send a message to this account.
SMTPClientSimulator oSMTP = new SMTPClientSimulator();
for (int i = 0; i < 3; i++)
oSMTP.Send("[email protected]", "[email protected]", "Test1", "This is a test of IMAP Search");
IMAPSimulator.AssertMessageCount("[email protected]", "test", "INBOX", 3);
// There should be 3 UID's, 1,2,3 or similar. No skips in the middle fo them.
IMAPSimulator oSimulator = new IMAPSimulator();
string sWelcomeMessage = oSimulator.Connect();
oSimulator.Logon("[email protected]", "test");
Assert.IsTrue(oSimulator.SelectFolder("INBOX"));
string result = oSimulator.SendSingleCommand("* UID SEARCH UID 1:*");
// Potentially, the response is multiline. (UID RESPONSE and an OK line). We only want the first line...
result = result.Substring(0, result.IndexOf("\r\n"));
string [] tokens = Microsoft.VisualBasic.Strings.Split(result, " ", -1, Microsoft.VisualBasic.CompareMethod.Text);
List<int> uids = new List<int>();
foreach (string token in tokens)
{
int temp;
if (Int32.TryParse(token, out temp))
{
uids.Add(temp);
}
}
Assert.AreEqual(3, uids.Count, result);
Assert.AreEqual(1, uids[0]);
Assert.AreEqual(2, uids[1]);
Assert.AreEqual(3, uids[2]);
}
示例8: TestRenameSubFolderToMatchingName
public void TestRenameSubFolderToMatchingName()
{
hMailServer.Account account = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "[email protected]", "test");
IMAPSimulator oSimulator = new IMAPSimulator();
Assert.IsTrue(oSimulator.ConnectAndLogon(account.Address, "test"));
Assert.IsTrue(oSimulator.CreateFolder("Folder1"));
Assert.IsTrue(oSimulator.SelectFolder("Folder1"));
string result = string.Empty;
Assert.IsFalse(oSimulator.RenameFolder("Folder1", "Folder1.Sub1", out result));
Assert.IsTrue(result.Contains("A folder cannot be moved into one of its subfolders."));
Assert.IsTrue(oSimulator.SelectFolder("Folder1"));
result = string.Empty;
Assert.IsTrue(oSimulator.RenameFolder("Folder1", "Folder1Test", out result));
Assert.IsTrue(oSimulator.SelectFolder("Folder1Test"));
oSimulator.Disconnect();
}
示例9: TestRenameLongFolder
public void TestRenameLongFolder()
{
hMailServer.Account oAccount = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "[email protected]", "test");
IMAPSimulator oSimulator = new IMAPSimulator();
string sWelcomeMessage = oSimulator.Connect();
oSimulator.LogonWithLiteral(oAccount.Address, "test");
Assert.IsTrue(oSimulator.CreateFolder("1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22.23.24.25"));
Assert.IsTrue(oSimulator.CreateFolder("A"));
Assert.IsFalse(oSimulator.RenameFolder("1", "A.1"));
Assert.IsTrue(oSimulator.RenameFolder("1.2.3", "A.1"));
Assert.IsTrue(oSimulator.SelectFolder("A.1.4"));
oSimulator.Disconnect();
}
示例10: TestBasics
public void TestBasics()
{
// Fetch the default domain
// Add an account
hMailServer.Account oAccount = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "[email protected]", "test");
// Add a rule to this account.
SingletonProvider<Utilities>.Instance.AddSpamRule(oAccount);
SingletonProvider<Utilities>.Instance.AddCorporateRule(oAccount);
SingletonProvider<Utilities>.Instance.AddExactMatchRule(oAccount);
SMTPClientSimulator oSMTP = new SMTPClientSimulator();
// Spam folder
oSMTP.Send("[email protected]", "[email protected]", "**SPAM** INBOX->SPAM", "Detta ska hamna i mappen Inbox\\Spam");
// Corporate folder
oSMTP.Send("[email protected]", "[email protected]", "**CORPORATE** INBOX->CORPORATE", "Detta ska hamna i mappen Inbox\\Corporate");
oSMTP.Send("[email protected]", "[email protected]", "CORPORATE EXACT MATCH", "Detta ska hamna i mappen Inbox\\Corporate");
// Inbox folder
oSMTP.Send("[email protected]", "[email protected]", "**CORPORATE EXACT MATCH**", "Detta ska hamna i mappen Inbox");
oSMTP.Send("[email protected]", "[email protected]", "INBOX", "Detta ska hamna i mappen Inbox");
oSMTP.Send("[email protected]", "[email protected]", "INBOX", "Detta ska hamna i mappen Inbox");
oSMTP.Send("[email protected]", "[email protected]", "INBOX", "Detta ska hamna i mappen Inbox");
IMAPSimulator.AssertMessageCount("[email protected]", "test", "Inbox.Spam", 1);
IMAPSimulator.AssertMessageCount("[email protected]", "test", "Inbox.Corporate", 2);
IMAPSimulator.AssertMessageCount("[email protected]", "test", "Inbox", 4);
// Test move to imap with mail with multiple recipients.
hMailServer.Account oAccount1 = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "[email protected]", "test");
hMailServer.Account oAccount2 = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "[email protected]", "test");
SingletonProvider<Utilities>.Instance.AddSpamRule(oAccount1);
// Send email to both recipients
List<string> lstRecipients = new List<string>();
lstRecipients.Add("[email protected]");
lstRecipients.Add("[email protected]");
string sBody = "Test of sending same email to multiple accounts.";
oSMTP.Send(oAccount1.Address, lstRecipients, "**SPAM** INBOX->SPAM", sBody);
IMAPSimulator.AssertMessageCount(oAccount1.Address, "test", "Inbox.Spam", 1);
IMAPSimulator.AssertMessageCount(oAccount2.Address, "test", "Inbox", 1);
IMAPSimulator sim = new IMAPSimulator();
sim.ConnectAndLogon(oAccount2.Address, "test");
Assert.IsFalse(sim.SelectFolder("Inbox.Spam"));
}
示例11: TestSearchWithLiterals
public void TestSearchWithLiterals()
{
hMailServer.Application application = SingletonProvider<Utilities>.Instance.GetApp();
;
hMailServer.Account oAccount = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "[email protected]", "test");
// Send a message to this account.
SMTPClientSimulator oSMTP = new SMTPClientSimulator();
oSMTP.Send("[email protected]", "[email protected]", "Test1", "This is a test of IMAP Search");
IMAPSimulator.AssertMessageCount("[email protected]", "test", "INBOX", 1);
oSMTP.Send("[email protected]", "[email protected]", "Test2", "This is a test of IMAP Search");
IMAPSimulator.AssertMessageCount("[email protected]", "test", "INBOX", 2);
IMAPSimulator oSimulator = new IMAPSimulator();
string sWelcomeMessage = oSimulator.Connect();
oSimulator.Logon("[email protected]", "test");
Assert.IsTrue(oSimulator.SelectFolder("INBOX"));
string result = oSimulator.SendSingleCommandWithLiteral("A01 SEARCH HEADER SUBJECT {5}", "Test1");
Assert.IsTrue(result.StartsWith("* SEARCH 1\r\n"));
result = oSimulator.SendSingleCommandWithLiteral("A01 SEARCH HEADER SUBJECT {5}", "Test2");
Assert.IsTrue(result.StartsWith("* SEARCH 2\r\n"));
}
示例12: TestSearchUSASCII
public void TestSearchUSASCII()
{
hMailServer.Account account = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "[email protected]", "test");
SMTPClientSimulator.StaticSend(account.Address, account.Address, "MySubject", "MyBody");
POP3Simulator.AssertMessageCount(account.Address, "test", 1);
IMAPSimulator oSimulator = new IMAPSimulator();
Assert.IsTrue(oSimulator.ConnectAndLogon(account.Address, "test"));
Assert.IsTrue(oSimulator.SelectFolder("INBOX"));
string result = oSimulator.Search("CHARSET US-ASCII ALL SUBJECT MySubject");
Assert.AreEqual("1", result);
result = oSimulator.Search("CHARSET US-ASCII ALL SUBJECT MySubjact");
Assert.AreEqual("", result);
}
示例13: TestSubjectSearchValueWithParanthesis
public void TestSubjectSearchValueWithParanthesis()
{
hMailServer.Domain oDomain = _application.Domains[0];
hMailServer.Account oAccount = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "[email protected]", "test");
// Send a message to this account.
SMTPClientSimulator oSMTP = new SMTPClientSimulator();
oSMTP.Send("[email protected]", "[email protected]", "Te(st1", "This is a test of IMAP Search");
IMAPSimulator.AssertMessageCount("[email protected]", "test", "INBOX", 1);
oSMTP.Send("[email protected]", "[email protected]", "Te)st2", "This is a test of IMAP Search");
IMAPSimulator.AssertMessageCount("[email protected]", "test", "INBOX", 2);
IMAPSimulator oSimulator = new IMAPSimulator();
string sWelcomeMessage = oSimulator.Connect();
oSimulator.Logon("[email protected]", "test");
Assert.IsTrue(oSimulator.SelectFolder("INBOX"));
Assert.AreEqual("1", oSimulator.Sort("(SUBJECT) UTF-8 ALL HEADER SUBJECT \"Te(st1\""));
Assert.AreEqual("2", oSimulator.Sort("(SUBJECT) UTF-8 ALL HEADER SUBJECT \"Te)st2\""));
}
示例14: TestSortSubjectSearch
public void TestSortSubjectSearch()
{
hMailServer.Domain oDomain = _application.Domains[0];
hMailServer.Account oAccount = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "[email protected]", "test");
// Send a message to this account.
SMTPClientSimulator oSMTP = new SMTPClientSimulator();
oSMTP.Send("[email protected]", "[email protected]", "aa", "This is a test of IMAP Search");
IMAPSimulator.AssertMessageCount("[email protected]", "test", "INBOX", 1);
oSMTP.Send("[email protected]", "[email protected]", "bb", "This is a test of IMAP Search");
IMAPSimulator.AssertMessageCount("[email protected]", "test", "INBOX", 2);
IMAPSimulator oSimulator = new IMAPSimulator();
string sWelcomeMessage = oSimulator.Connect();
oSimulator.Logon("[email protected]", "test");
Assert.IsTrue(oSimulator.SelectFolder("INBOX"));
Assert.AreEqual("1 2", oSimulator.Sort("(DATE) UTF-8 ALL UNANSWERED OR HEADER SUBJECT aa HEADER SUBJECT bb"));
Assert.AreEqual("1 2", oSimulator.Sort("(DATE) UTF-8 ALL UNANSWERED OR (HEADER SUBJECT aa) (HEADER SUBJECT bb)"));
Assert.AreEqual("1 2", oSimulator.Sort("(DATE) UTF-8 ALL UNANSWERED (OR HEADER SUBJECT aa HEADER SUBJECT bb)"));
Assert.AreEqual("1", oSimulator.Sort("(DATE) UTF-8 ALL UNANSWERED OR HEADER SUBJECT aa HEADER SUBJECT cc"));
Assert.AreEqual("1", oSimulator.Sort("(DATE) UTF-8 ALL UNANSWERED OR (HEADER SUBJECT aa) (HEADER SUBJECT cc)"));
Assert.AreEqual("1", oSimulator.Sort("(DATE) UTF-8 ALL UNANSWERED (OR HEADER SUBJECT aa HEADER SUBJECT cc)"));
Assert.AreEqual("2", oSimulator.Sort("(DATE) UTF-8 ALL UNANSWERED OR HEADER SUBJECT bb HEADER SUBJECT cc"));
Assert.AreEqual("2", oSimulator.Sort("(DATE) UTF-8 ALL UNANSWERED OR (HEADER SUBJECT bb) (HEADER SUBJECT cc)"));
Assert.AreEqual("2", oSimulator.Sort("(DATE) UTF-8 ALL UNANSWERED (OR HEADER SUBJECT bb HEADER SUBJECT cc)"));
}
示例15: TestSortReverseSize
public void TestSortReverseSize()
{
hMailServer.Domain oDomain = _application.Domains[0];
hMailServer.Account oAccount = SingletonProvider<Utilities>.Instance.AddAccount(_domain, "[email protected]", "test");
StringBuilder longBodyString = new StringBuilder();
longBodyString.Append('A', 10000);
// Send a message to this account.
SMTPClientSimulator oSMTP = new SMTPClientSimulator();
oSMTP.Send("[email protected]", "[email protected]", "Test1", longBodyString.ToString());
IMAPSimulator.AssertMessageCount("[email protected]", "test", "INBOX", 1);
oSMTP.Send("[email protected]", "[email protected]", "Test2", "Test body");
IMAPSimulator.AssertMessageCount("[email protected]", "test", "INBOX", 2);
IMAPSimulator oSimulator = new IMAPSimulator();
string sWelcomeMessage = oSimulator.Connect();
oSimulator.Logon("[email protected]", "test");
Assert.IsTrue(oSimulator.SelectFolder("INBOX"));
Assert.AreEqual("2 1", oSimulator.Sort("(SIZE) UTF-8 ALL"));
Assert.AreEqual("1 2", oSimulator.Sort("(REVERSE SIZE) UTF-8 ALL"));
}