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("服務(wù)器拒絕連接,可能密碼錯誤!");
imap.Dispose();
}
}
}
}
相關(guān)文章
C#調(diào)用OutLokk實現(xiàn)發(fā)送郵件
這篇文章主要為大家詳細(xì)介紹了如何利用C#調(diào)用OutLokk實現(xiàn)發(fā)送郵件的功能,文中的示例代碼講解詳細(xì),對我們學(xué)習(xí)C#有一定的幫助,感興趣的小伙伴可以跟隨小編一起了解一下2022-12-12
理解C#中參數(shù)的值和引用以及傳遞結(jié)構(gòu)和類引用的區(qū)別
這篇文章主要介紹了理解C#中參數(shù)的值和引用以及傳遞結(jié)構(gòu)和類引用的區(qū)別,文中舉了兩段代碼例子來簡單說明,需要的朋友可以參考下2016-01-01

