コード例 #1
0
ファイル: ImapMailboxTest.cs プロジェクト: myrdev/SampleCode
 public void CheckList()
 {
     ImapConnect connection = new ImapConnect(_host, _port, _ssl);
     ImapCommand command = new ImapCommand(connection);
     ImapAuthenticate authenticate = new ImapAuthenticate(connection, _user, _pass);
     connection.Open();
     authenticate.Login();
     command.List();
     authenticate.Logout();
     connection.Close();
 }
コード例 #2
0
ファイル: ImapMailboxTest.cs プロジェクト: myrdev/SampleCode
 public void CheckBodyStructure()
 {
     ImapConnect connection = new ImapConnect(_host, _port, _ssl);
     ImapCommand command = new ImapCommand(connection);
     ImapAuthenticate authenticate = new ImapAuthenticate(connection, _user, _pass);
     connection.Open();
     authenticate.Login();
     ImapMailbox mailbox = command.Select("INBOX");
     ImapMailboxMessage message = new ImapMailboxMessage();
     message.ID = 1;
     message = command.FetchBodyStructure(message);
     authenticate.Logout();
     connection.Close();
 }
コード例 #3
0
 public void ImapFullCramMd5Test()
 {
     _connection = new ImapConnect(_stdhost);
     _authentication = new ImapAuthenticate(_connection, _stduser, _stdpass);
     _command = new ImapCommand(_connection);
     _connection.LoginType = LoginType.CRAM_MD5;
     Assert.IsTrue(_connection.Open());
     Assert.IsTrue(_connection.State == ConnectionState.Connected);
     _authentication.Login();
     Assert.IsTrue(_connection.State == ConnectionState.Open);
     _mailbox = _command.Examine("Inbox");
     Assert.IsTrue(_mailbox.Exist != 0);
     _authentication.Logout();
     Assert.IsTrue(_connection.State == ConnectionState.Closed);
     _connection.Close();
     _connection.Dispose();
 }
コード例 #4
0
ファイル: ImapMailboxTest.cs プロジェクト: myrdev/SampleCode
 public void EntireInbox()
 {
     try
     {
         ImapConnect connection = new ImapConnect(_host, _port, _ssl);
         ImapCommand command = new ImapCommand(connection);
         ImapAuthenticate authenticate = new ImapAuthenticate(connection, _user, _pass);
         connection.Open();
         authenticate.Login();
         ImapMailbox mailbox = command.Select("INBOX");
         mailbox = command.Fetch(mailbox);
         authenticate.Logout();
         connection.Close();
         Assert.That(true);
     }
     catch (Exception)
     {
         Assert.That(false);
     }
 }
コード例 #5
0
 public void ImapFullSslPlainTest()
 {
     _connection = new ImapConnect(_sslhost, 993, true);
     _authentication = new ImapAuthenticate(_connection, _ssluser, _sslpass);
     _command = new ImapCommand(_connection);
     Assert.IsTrue(_connection.Open());
     Assert.IsTrue(_connection.State == ConnectionState.Connected);
     _connection.LoginType = LoginType.PLAIN;
     _authentication.Login();
     Assert.IsTrue(_connection.State == ConnectionState.Open);
     _mailbox = _command.Examine("Inbox");
     Assert.IsTrue(_mailbox.Exist != 0);
     _authentication.Logout();
     Assert.IsTrue(_connection.State == ConnectionState.Closed);
     _connection.Close();
     _connection.Dispose();
 }
コード例 #6
0
ファイル: Koolwired.cs プロジェクト: myrdev/SampleCode
        public static void KoolwiredExample()
        {
            ImapConnect conn = new ImapConnect("SERVER", 993, true);
            ImapCommand cmd = new ImapCommand(conn);
            ImapAuthenticate auth = new ImapAuthenticate(conn, "EMAIL/USERNAME", "PASSWORD");

            //try
            conn.Open();
            auth.Login();

            /*
             * Initial example > http://stackoverflow.com/questions/1530724/imap-on-c-sharp-download-mails-and-attachments
             *
             * gmail vb example > http://www.vbforums.com/showthread.php?588947-RESOLVED-Koolwired-IMAP-and-Gmail
             *
             * sample Koolwired attachment DL > http://stackoverflow.com/questions/14504091/i-am-using-koolwired-imap-to-retrieve-attachments-via-imap
             *
             * IMAP spec > http://dovecot.org/imap-client-coding-howto.html
             *
             * IMAP crib sheet > http://donsutherland.org/crib/imap
             *
             * List bug > http://sourceforge.net/p/imapnet/discussion/704327/thread/192fee31/
             */

            string htmlbody = "";
            var m = cmd.List();
            ImapMailbox mailbox = cmd.Select("%");
            mailbox = cmd.Fetch(mailbox);
            //int mailCount = mailbox.Messages.Count;

            //for (int i = 0; i < mailCount; i++)
            //{
            //    ImapMailboxMessage msg = mailbox.Messages[mailCount - 1];
            //    msg = cmd.FetchBodyStructure(msg);

            //    msg.BodyParts[0].ContentEncoding = BodyPartEncoding.NONE;
            //    msg = cmd.FetchBodyPart(msg, msg.HTML);

            //    foreach (ImapMessageBodyPart a in msg.BodyParts)
            //    {
            //        if (a.Data != null)
            //        {
            //            string fileName = "";
            //            Console.Write("I found an attachment ");

            //            //if (a.Attachment) fileName = ParseFileName(a.Disposition);
            //            //string mimeType = a.ContentType.MediaType.ToLower();

            //            //a.ContentEncoding = BodyPartEncoding.UTF7;
            //            //htmlbody = a.Data;
            //        }
            //    }
            //}

            auth.Logout();
            conn.Close();
            //catch ex as Exception
            //    Console.WriteLine(ex.ToString());
            //end try

            Console.ReadKey();
        }
コード例 #7
0
 public override void SetConfig(string host, int port, bool useSSL, string username, string password)
 {
     _connection = new ImapConnect(host, port, useSSL);
     _command = new ImapCommand(_connection);
     _authenticate = new ImapAuthenticate(_connection, username, password);
 }