public void Receive(string uploadingPath) { if(string.IsNullOrEmpty(uploadingPath)) throw new ArgumentNullException("uploadingPath"); if(!Directory.Exists(uploadingPath)) throw new ArgumentException("一時保存用のフォルダがありません", "uploadingPath"); // 受信してファイルに保存後、DBにメタ情報を登録 using(var pop3 = new Pop3()) { var connected = pop3.Connect(_server, _port, _secure); if(!connected.Successed) return; var loggedIn = pop3.Login(_userName, _password); if(!loggedIn.Successed) return; var received = pop3.GetMessageItems(); if(!received.Successed) return; foreach (var item in received.Items) { InternalReceive(uploadingPath, pop3, item); } // 削除の確定 pop3.CommandQuit(); } }
public void 全メール削除() { Response response; using (var pop3 = new Pop3()) { pop3.Connect(_server, _port, _secure); pop3.Login(_userName, _password); response = pop3.GetMessageItems(); // 全部消す foreach (var item in response.Items.Where(i => i.No > TestMailMaxNo)) { pop3.CommandDele(item.No); } pop3.CommandQuit(); } }
public void メッセージを取得() { SendTestMail(_userName); Response response; using (var pop3 = new Pop3()) { response = pop3.Connect(_server, _port, _secure); Console.WriteLine(response.Trace); response = pop3.Login(_userName, _password); Console.WriteLine(response.Trace); response = pop3.GetMessageItems(); Console.WriteLine(response.Trace); if (response.Items.Any()) { var messageNo = response.Items.First().No; response = pop3.CommandRetr(messageNo); Console.WriteLine(response.Trace); Console.WriteLine(response.Message.Source); } } Assert.IsTrue(response.Successed); }
public void メッセージ一覧を取得() { SendTestMail(_userName); Response response; using (var pop3 = new Pop3()) { response = pop3.Connect(_server, _port, _secure); Console.WriteLine(response.Trace); response = pop3.Login(_userName, _password); Console.WriteLine(response.Trace); response = pop3.GetMessageItems(); Console.WriteLine(response.Trace); Console.WriteLine(response.Items.Count + " messages"); } Assert.IsTrue(response.Successed); Assert.IsTrue(response.Items.Any()); }
public void メッセージを削除() { SendTestMail(_userName); Response response; using (var pop3 = new Pop3()) { response = pop3.Connect(_server, _port, _secure); Console.WriteLine(response.Trace); response = pop3.Login(_userName, _password); Console.WriteLine(response.Trace); response = pop3.GetMessageItems(); Console.WriteLine(response.Trace); Console.WriteLine(response.Items.Count + " messages"); // 全部消す foreach (var item in response.Items.Where(i => i.No > TestMailMaxNo)) { response = pop3.CommandDele(item.No); Assert.IsTrue(response.Successed); Console.WriteLine(response.Trace); } response = pop3.CommandQuit(); Console.WriteLine(response.Trace); } Assert.IsTrue(response.Successed); }