欢迎来到代码驿站!

.NET代码

当前位置:首页 > 软件编程 > .NET代码

c#使用S22.Imap收剑灵激活码邮件代码示例(imap收邮件)

时间:2021-04-02 09:47:09|栏目:.NET代码|点击:

复制代码 代码如下:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using S22.Imap;

namespace _163pop3
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }
        /*
 * 
 *  By im0khu 
 *  C#利用IMAP收邮件
 */
        private void btnFetch_Click(object sender, EventArgs e)
        {

            string ImapServer = "imap.163.com";
            string ImapUserame = "xiagegou_com";
            string ImapPwd = "password2013";
            ImapClient imap = new ImapClient(ImapServer, 993, true);

            try
            {
                imap.Login(ImapUserame, ImapPwd, AuthMethod.Login);
                uint[] uids = imap.Search(SearchCondition.Subject("This's a test email"));
               // uint[] uids = imap.Search(SearchCondition.From("ssss@oschina.net"));
      // 也可以使用通过其它条件进行检索你的邮件
               if (uids.Length > 0)
                {
                    System.Net.Mail.MailMessage msg = imap.GetMessage(uids[0]);
                    emailLst.Items.Add("Subject: " + msg.Subject);
                    emailBody.Text = msg.Body;                  

                }
                else
                {
                    emailLst.Items.Add("没有你要找的邮件");
                }
                imap.Dispose();

            }
            catch (InvalidCredentialsException)
            {
                MessageBox.Show("服务器拒绝连接,可能密码错误!");
                imap.Dispose();
            }
        }
    }
}

上一篇:asp.net core 腾讯验证码的接入示例代码

栏    目:.NET代码

下一篇:Asp.net SignalR支持的平台有哪些

本文标题:c#使用S22.Imap收剑灵激活码邮件代码示例(imap收邮件)

本文地址:http://www.codeinn.net/misctech/93087.html

推荐教程

广告投放 | 联系我们 | 版权申明

重要申明:本站所有的文章、图片、评论等,均由网友发表或上传并维护或收集自网络,属个人行为,与本站立场无关。

如果侵犯了您的权利,请与我们联系,我们将在24小时内进行处理、任何非本站因素导致的法律后果,本站均不负任何责任。

联系QQ:914707363 | 邮箱:codeinn#126.com(#换成@)

Copyright © 2020 代码驿站 版权所有