コード例 #1
0
        public JsonResult GetMail()
        {
            Pop3Client client = new Pop3Client();

            client.Connect("pop.asia.secureserver.net", 110, false);
            client.Authenticate("*****@*****.**", "passward");
            var             count    = client.GetMessageCount();
            List <MailData> maildata = new List <MailData>();
            MailData        mail     = null;

            //var datamail1 = client.GetMessage(1);
            //var datamail2= client.GetMessage(2);
            //var datamail3 = client.GetMessage(3);
            //var datamail4 = client.GetMessage(4);
            for (int i = 2; i <= count; i++)
            {
                mail             = new MailData();
                mail.MailHeading = client.GetMessage(i).Headers.Subject.ToString();
                //mail.MailBody = (client.GetMessage(i)).MessagePart.GetBodyAsText().ToString();
                maildata.Add(mail);
            }
            if (count > 0)
            {
                for (int i = 1; i < count; i++)
                {
                    mail = new MailData();
                    //var datamail  =  client.GetMessage(i);
                    // mail.MailHeading = datamail.RawMessage.ToString();
                }
            }

            var message = client.GetMessage(count);

            return(Json(message, JsonRequestBehavior.AllowGet));
        }
コード例 #2
0
        public JsonResult SandMail(MailData maildata)
        {
            //string orgid = Session["OrgId"].ToString();
            //string userid = Session["UserId"].ToString();

            string orgid  = User.OrgId;
            string userid = User.UserId;

            string frommailid       = string.Empty;
            bool   samdmail         = false;
            string msg              = string.Empty;
            string usermailpassword = string.Empty;

            using (EPortalEntities entity = new EPortalEntities())
            {
                var userdata = (from u in entity.UserInfoes
                                where u.Id == userid &&
                                u.OrganizationID == orgid
                                select u).FirstOrDefault();
                if (userdata != null)
                {
                    //frommailid = userdata.Email;
                    //usermailpassword = userdata.UserPassword;
                }
            }
            //if (!String.IsNullOrWhiteSpace(frommailid))
            //{
            samdmail = homecontroller.SendMail(maildata.MailTo, maildata.MailHeading, maildata.MailBody, null, frommailid, usermailpassword);
            //}
            //else
            //{
            //    msg = "Mail id not configure for login user.";
            //}
            return(Json(new { samdmail = samdmail, msg = msg }, JsonRequestBehavior.AllowGet));
        }