c#使用S22.Imap收劍靈激活碼郵件代碼示例(imap收郵件)
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#使用WMI實現(xiàn)監(jiān)聽進程的啟動和關閉
Windows Management Instrumentation(WMI)是用于管理基于 Windows 操作系統(tǒng)的數(shù)據(jù)和操作的基礎結構,本文將使用WMI實現(xiàn)監(jiān)聽進程的啟動和關閉,感興趣的可以了解下2024-01-01C# string格式的日期時間字符串轉為DateTime類型的方法
這篇文章主要介紹了C# string格式的日期時間字符串轉為DateTime類型的方法,需要的朋友可以參考下2017-02-02程序中兩個Double類型相加出現(xiàn)誤差的解決辦法
本篇文章介紹了,程序中兩個Double類型相加出現(xiàn)誤差的解決辦法。需要的朋友參考下2013-04-04C#中datagridview使用tooltip控件顯示單元格內容的方法
這篇文章主要介紹了C#中datagridview使用tooltip控件顯示單元格內容的方法,實例分析了C#控件的相關使用技巧,需要的朋友可以參考下2016-06-06