如何使用 LumiSoft.Net

 资源地址



获取 email

public List<Mime> GetEmails(string pop3Server, string pop3Port, string username, string password)
        {
            bool pop3UseSsl = false;
            List<string> gotEmailIds = new List<string>();
            List<Mime> result = new List<Mime>();
            using (POP3_Client pop3 = new POP3_Client())
            {
                try
                {
                    pop3.Connect(pop3Server, Convert.ToInt32(pop3Port), pop3UseSsl);
                    pop3.Authenticate(username, password, false);
                    POP3_ClientMessageCollection infos = pop3.Messages;
                    foreach (POP3_ClientMessage info in infos)
                    {
                        if (gotEmailIds.Contains(info.UID))
                            continue;
                        byte[] bytes = info.MessageToByte();
                        gotEmailIds.Add(info.UID);
                        Mime mime = Mime.Parse(bytes);
                        result.Add(mime);
                    }
                }
                catch (Exception ex)
                {
                    throw new Exception(ex.Message);
                }
            }
            return result;
        }

删除 email

public void DeleteMail()
        {
            using (POP3_Client c = new POP3_Client())
            {
                c.Connect(pop3Server, Convert.ToInt32(pop3Port));
                c.Authenticate(username, password, false);
                if (c.Messages.Count > 0)
                {
                    foreach (POP3_ClientMessage mail in c.Messages)
                    {
                        mail.MarkForDeletion();
                    }
                }
            }
        }



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值