示例#1
0
        protected void GetApplicationsFromGmail()
        {
            string xmlString = string.Empty;
            MailRepository rep = new MailRepository("imap.gmail.com", 993, true, @"*****@*****.**", @"dhamma@xml");
            foreach (Message email in rep.GetUnreadMails("Applications"))
            {
                // Response.Write(string.Format("<p>{0}: {1}</p><p>{2}</p>", email.From, email.Subject, email.BodyHtml.Text));
                if (email.From.Email == "*****@*****.**")
                {
                    if (email.Attachments.Count > 0)
                    {
                        foreach (MimePart attachment in email.Attachments)
                        {
                            //attachment.
                            //  attachment.TextContent
            //attachment.StoreToFile(Server.MapPath(".") + "/Applications/"+attachment.ContentName);
                            xmlString = attachment.TextContent;
                            lstAppXML.Add(xmlString);
                            ReadXmlApplication(xmlString);

                        }
                    }
                }
            }

            InsertApplication();
        }
示例#2
0
        protected void TestMail()
        {
            MailRepository rep = new MailRepository("imap.gmail.com", 993, true, @"*****@*****.**", @"dhamma@xml");

            foreach (Message email in rep.GetUnreadMails("Inbox"))
            {
                Response.Write(string.Format("<p>{0}: {1}</p><p>{2}</p>", email.From, email.Subject, email.BodyHtml.Text));
                if (email.Attachments.Count > 0)
                {
                    foreach (MimePart attachment in email.Attachments)
                    {
                        //attachment.
                        //  attachment.TextContent
                        Response.Write(string.Format("<p>Attachment: {0} {1}</p><br/>{2}", attachment.ContentName, attachment.ContentType.MimeType, attachment.TextContent));
                    }
                }
            }
        }