Exemplo n.º 1
0
        public ActionResult DetailMail(long id)
        {
            Email Email = new Email();
            Imap  imp   = new Imap();

            // Connect to the server, login and select inbox.
            imp.Connect("IMAP.gmail.com");
            imp.Login("*****@*****.**", "tantan1193");
            imp.SelectFolder("INBOX");
            EnvelopeCollection envelopes = imp.DownloadEnvelopes(Imap.AllMessages, false);

            envelopes.Reverse();
            foreach (Envelope env in envelopes)
            {
                if (id == env.Uid)
                {
                    Email.subject = env.Subject;
                    Email.name    = env.From;
                    Email.Date    = env.Date;

                    break;
                }
            }
            // Disconnect from the server.
            imp.Disconnect();
            return(View(Email));
        }
Exemplo n.º 2
0
        public ActionResult Index(FormCollection form, string typeName)
        {
            var inputCheck = form.GetValues("inputCheck");

            ViewBag.Mess = EvenList(inputCheck, typeName);
            List <Email> Email = new List <Email>();
            Imap         imp   = new Imap();

            // Connect to the server, login and select inbox.
            imp.Connect("IMAP.gmail.com");
            imp.Login("*****@*****.**", "tantan1193");
            imp.SelectFolder("INBOX");
            // Get envelopes for the specified messages.
            EnvelopeCollection envelopes = imp.DownloadEnvelopes(Imap.AllMessages, false);

            // Make newer messages be displayed first.
            envelopes.Reverse();

            foreach (Envelope env in envelopes)
            {
                Email.Add(new Email()
                {
                    Uid     = env.Uid,
                    subject = env.Subject,
                    name    = env.From,
                    Date    = env.Date
                });
            }
            // Disconnect from the server.
            imp.Disconnect();
            return(View(Email.ToList()));
        }
Exemplo n.º 3
0
        public int DeleteConfirmed(string[] inputCheck)
        {
            Email Email = new Email();
            Imap  imp   = new Imap();

            // Connect to the server, login and select inbox.
            imp.Connect("IMAP.gmail.com");
            imp.Login("*****@*****.**", "tantan1193");
            imp.SelectFolder("INBOX");
            EnvelopeCollection envelopes = imp.DownloadEnvelopes(Imap.AllMessages, false);

            envelopes.Reverse();
            int rowFinish = 0;

            if (inputCheck == null)
            {
                return(rowFinish);
            }
            foreach (var s in inputCheck)
            {
                long idMenu = Convert.ToInt32(DefineFuntion.Decrypt(s));
                foreach (Envelope env in envelopes)
                {
                    if (idMenu == env.Uid)
                    {
                        imp.DeleteMessages(env.Uid.ToString(), true);
                        break;
                    }
                }
            }

            // Disconnect from the server.
            imp.Disconnect();
            return(rowFinish);
        }
Exemplo n.º 4
0
        // GET: MailBox
        public ActionResult Index( )

        {
            List <Email> Email = new List <Email>();
            Imap         imp   = new Imap();

            //imp.DeleteMessages(, true);
            // Connect to the server, login and select inbox.
            imp.Connect("IMAP.gmail.com");
            imp.Login("*****@*****.**", "tantan1193");
            imp.SelectFolder("INBOX");
            string range;

            // Does the inbox contain at least 10 mails?
            if (imp.MessageCount >= 10)
            {
                // We'll get last 10 mails.
                range = (imp.MessageCount - 9).ToString() + ":" + "*";
            }
            else
            {
                // We'll get all mails.
                range = Imap.AllMessages;
            }

            // Get envelopes for the specified messages.
            EnvelopeCollection envelopes = imp.DownloadEnvelopes(range, false);

            // Make newer messages be displayed first.
            envelopes.Reverse();

            foreach (Envelope env in envelopes)
            {
                Email.Add(new Email()
                {
                    Uid     = env.Uid,
                    subject = env.Subject,
                    name    = env.From,
                    Date    = env.Date
                });
            }
            // Disconnect from the server.
            imp.Disconnect();
            return(View(Email.ToList()));
        }