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

Janna ·
更新时间:2024-11-14
· 526 次阅读

代码如下:
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();
            }
        }
    }
}

您可能感兴趣的文章:c#使用IMap收取163邮件的方法示例PHP基于IMAP收取邮件的方法示例Java+Nginx实现POP、IMAP、SMTP邮箱代理服务PHP基于imap获取邮件实例用PHP读取IMAP邮件使用c#+IMap实现收取163邮件



激活 C# 示例 imap 邮件

需要 登录 后方可回复, 如果你还没有账号请 注册新账号