Example #1
0
        public Mail Summary(MlMailDb mlDb, MlSubject mlSubject, int start, int end)
        {
            //ライブラリからの取得
            Encoding      encoding = null;
            StringBuilder sb       = new StringBuilder();

            for (int i = start; i <= end; i++)
            {
                var mail = mlDb.Read(i);
                if (mail == null)
                {
                    sb.Append(mlSubject.Get(i) + " library no't found.\r\n");
                }
                else
                {
                    string str = mail.GetHeader("subject");
                    if (str != null)
                    {
                        str = Subject.Decode(ref encoding, str);
                        sb.Append(string.Format("{0}\r\n", str));
                    }
                    else
                    {
                        sb.Append(mlSubject.Get(i) + " subject no't found.\r\n");
                    }
                }
            }
            string subject = string.Format("result for summary [{0}-{1}] ({2} ML)", start, end, mlAddr.Name);

            return(Create(ContentTyep.Sjis, subject, sb.ToString()));
        }
Example #2
0
        Mail Summary1(int start, int end)
        {
            //実際に取得したライブラリ番号
            var s = -1;
            var e = -1;

            Encoding encoding = null;
            var      sb       = new StringBuilder();

            //ライブラリからの取得
            for (int i = start; i <= end; i++)
            {
                var mail = _mlDb.Read(i);
                if (mail == null)
                {
                    continue;
                }
                if (s == -1)
                {
                    s = i;
                    e = i;
                }
                else
                {
                    e = i;
                }
                string str = mail.GetHeader("subject");
                if (str != null)
                {
                    str = Subject.Decode(ref encoding, str);
                    sb.Append(string.Format("{0}\r\n", str));
                }
            }
            var subject = string.Format("result for summary [{0}-{1}] ({2} ML)", s, e, _mlAddr.Name);

            if (s == -1)  //1件も取得できなかった場合
            {
                subject = string.Format("not found No.{0} ({1} ML)", start, _mlAddr.Name);
            }
            return(Create(ContentTyep.Sjis, subject, sb.ToString()));
        }
Example #3
0
        public void SaveReadTest()
        {
            var tmpDir = TestUtil.GetTmpDir("$tmp");
            var logger = new Logger();

            var mail = new Mail();
            const string mlName = "1ban";
            var mlMailDb = new MlMailDb(logger, tmpDir, mlName);
            mlMailDb.Remove();//もし、以前のメールが残っていたらTESTが誤動作するので、ここで消しておく

            Assert.AreEqual(mlMailDb.Count(), 0);

            const int max = 10; //試験件数10件
            //保存と、
            for (int i = 0; i < max; i++) {
                var b = mlMailDb.Save( mail);
                Assert.AreEqual(b,true);//保存が成功しているか
                Assert.AreEqual(mlMailDb.Count(), i+1);//連番がインクリメントしているか
            }
            //範囲外のメール取得でnullが返るか
            //no==1..10が取得可能
            var m = mlMailDb.Read(0);//範囲外
            Assert.IsNull(m);
            //範囲内
            for (int no = 1; no <= max; no++) {
                //m = mlMailDb.Read(no);
                mlMailDb.Read(no);
                Assert.NotNull(mlMailDb.Read(no));
            }
            //範囲外
            m = mlMailDb.Read(11);
            Assert.IsNull(m);

            //TearDown
            mlMailDb.Remove();
            mlMailDb.Dispose();
            Directory.Delete(tmpDir,true);
        }
Example #4
0
        public Mail Get(MlMailDb mlDb, int start, int end)
        {
            string boundaryStr = "BJD-Boundary";

            byte[] buf = new byte[0];
            //ライブラリからの取得
            for (int i = start; i <= end; i++)
            {
                var mail = mlDb.Read(i);
                if (mail != null)
                {
                    buf = Bytes.Create(buf, Encoding.ASCII.GetBytes(string.Format("--{0}\r\n", boundaryStr)));
                    buf = Bytes.Create(buf, Encoding.ASCII.GetBytes("Content-Type: message/rfc822\r\n\r\n"));
                    buf = Bytes.Create(buf, mail.GetBytes());
                }
            }
            buf = Bytes.Create(buf, Encoding.ASCII.GetBytes(string.Format("--{0}--\r\n", boundaryStr)));

            var subject     = string.Format("result for get [{0}-{1} MIME/multipart] ({2} ML)", start, end, mlAddr.Name);
            var contentType = string.Format("multipart/mixed;\r\n boundary=\"{0}\"\r\n", boundaryStr);

            return(Create(subject, contentType, buf));
        }
Example #5
0
        public Mail Get(MlMailDb mlDb, int start, int end)
        {
            string boundaryStr = "BJD-Boundary";
            byte[] buf = new byte[0];
            //ライブラリからの取得
            for (int i = start; i <= end; i++) {
                var mail = mlDb.Read(i);
                if (mail != null) {
                    buf = Bytes.Create(buf, Encoding.ASCII.GetBytes(string.Format("--{0}\r\n", boundaryStr)));
                    buf = Bytes.Create(buf, Encoding.ASCII.GetBytes("Content-Type: message/rfc822\r\n\r\n"));
                    buf = Bytes.Create(buf, mail.GetBytes());
                }
            }
            buf = Bytes.Create(buf, Encoding.ASCII.GetBytes(string.Format("--{0}--\r\n", boundaryStr)));

            var subject = string.Format("result for get [{0}-{1} MIME/multipart] ({2} ML)", start, end, mlAddr.Name);
            var contentType = string.Format("multipart/mixed;\r\n boundary=\"{0}\"\r\n", boundaryStr);

            return Create(subject, contentType, buf);
        }
Example #6
0
 public Mail Summary(MlMailDb mlDb, MlSubject mlSubject, int start, int end)
 {
     //ライブラリからの取得
     Encoding encoding = null;
     StringBuilder sb = new StringBuilder();
     for (int i = start; i <= end; i++) {
         var mail = mlDb.Read(i);
         if (mail == null) {
             sb.Append(mlSubject.Get(i) + " library no't found.\r\n");
         } else {
             string str = mail.GetHeader("subject");
             if (str != null) {
                 str = Subject.Decode(ref encoding, str);
                 sb.Append(string.Format("{0}\r\n", str));
             } else {
                 sb.Append(mlSubject.Get(i) + " subject no't found.\r\n");
             }
         }
     }
     string subject = string.Format("result for summary [{0}-{1}] ({2} ML)", start, end, mlAddr.Name);
     return Create(ContentTyep.Sjis, subject, sb.ToString());
 }