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"));
// 也可以使用通過其它條件進(jìn)行檢索你的郵件
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("服務(wù)器拒絕連接,可能密碼錯誤!");
imap.Dispose();
}
}
}
}
相關(guān)文章
C#使用WMI實(shí)現(xiàn)監(jiān)聽進(jìn)程的啟動和關(guān)閉
Windows Management Instrumentation(WMI)是用于管理基于 Windows 操作系統(tǒng)的數(shù)據(jù)和操作的基礎(chǔ)結(jié)構(gòu),本文將使用WMI實(shí)現(xiàn)監(jiān)聽進(jìn)程的啟動和關(guān)閉,感興趣的可以了解下2024-01-01C# string格式的日期時(shí)間字符串轉(zhuǎn)為DateTime類型的方法
這篇文章主要介紹了C# string格式的日期時(shí)間字符串轉(zhuǎn)為DateTime類型的方法,需要的朋友可以參考下2017-02-02程序中兩個Double類型相加出現(xiàn)誤差的解決辦法
本篇文章介紹了,程序中兩個Double類型相加出現(xiàn)誤差的解決辦法。需要的朋友參考下2013-04-04C#中datagridview使用tooltip控件顯示單元格內(nèi)容的方法
這篇文章主要介紹了C#中datagridview使用tooltip控件顯示單元格內(nèi)容的方法,實(shí)例分析了C#控件的相關(guān)使用技巧,需要的朋友可以參考下2016-06-06總結(jié)C#網(wǎng)絡(luò)編程中對于Cookie的設(shè)定要點(diǎn)
這篇文章主要介紹了總結(jié)C#網(wǎng)絡(luò)編程中對于Cookie的設(shè)定要點(diǎn),文中還給出了一個cookie操作實(shí)例僅供參照,需要的朋友可以參考下2016-04-04