基于LumiSoft.Net.dll发、收、删邮件
发邮件:
using LumiSoft.Net.SMTP.Client; Mime m = new Mime();
MimeEntity mainEntity = m.MainEntity;
// Force to create From: header field
mainEntity.From = new AddressList();
mainEntity.From.Add(new MailboxAddress(txtFrom.Text, txtFrom.Text));
// Force to create To: header field
mainEntity.To = new AddressList();
mainEntity.To.Add(new MailboxAddress(txtTo.Text, txtTo.Text));
mainEntity.Subject = txtSubject.Text;
//添加正文
mainEntity.ContentType = MediaType_enum.Multipart_mixed;
MimeEntity textEntity = mainEntity.ChildEntities.Add();
textEntity.ContentType = MediaType_enum.Text_html;
textEntity.ContentTransferEncoding = ContentTransferEncoding_enum.Base64;
textEntity.DataText = txtBody.Text;
//发送附件
MimeEntity attachmentEntity = new MimeEntity();
attachmentEntity.ContentType = MediaType_enum.Application_octet_stream;
attachmentEntity.ContentDisposition = ContentDisposition_enum.Attachment;
attachmentEntity.ContentTransferEncoding = ContentTransferEncoding_enum.Base64;
attachmentEntity.ContentDisposition_FileName = "c:/test.jpg";
attachmentEntity.DataFromFile("c:/test.jpg"); mainEntity.ChildEntities.Add(attachmentEntity); SMTP_Client.QuickSend(m);
收邮件:
using LumiSoft.Net.POP3.Client;
using LumiSoft.Net;
using LumiSoft.Net.Mime;
[csharp] view plain copy
public List<Mime> GetEmails(string pop3Server, string pop3Port, string username, string password)
{
bool pop3UseSsl = false;
List<string> gotEmailIds = new List<string>();
List<Mime> result = new List<Mime>();
using (POP3_Client pop3 = new POP3_Client())
{
try
{
pop3.Connect(pop3Server, Convert.ToInt32(pop3Port), pop3UseSsl);
pop3.Authenticate(username, password, false);
POP3_ClientMessageCollection infos = pop3.Messages;
foreach (POP3_ClientMessage info in infos)
{
if (gotEmailIds.Contains(info.UID))
continue;
byte[] bytes = info.MessageToByte();
gotEmailIds.Add(info.UID);
Mime mime = Mime.Parse(bytes);
result.Add(mime);
}
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
return result;
}
删除邮件:
using LumiSoft.Net.POP3.Client;
using LumiSoft.Net;
using LumiSoft.Net.Mime;
[csharp] view plain copy
private void DeleteMail()
{
using (POP3_Client c = new POP3_Client())
{
c.Connect(pop3Server, Convert.ToInt32(pop3Port));
c.Authenticate(username, password, false);
if (c.Messages.Count > 0)
{
foreach (POP3_ClientMessage mail in c.Messages)
{
mail.MarkForDeletion();
}
}
}
}
基于LumiSoft.Net.dll发、收、删邮件的更多相关文章
- 基于Lumisoft.NET组件,使用IMAP协议收取邮件
在早期一直使用Lumisoft.NET组件来进行邮件的处理查找,对于邮件的处理非常方便,之前在随笔<基于Lumisoft.NET组件的POP3邮件接收和删除操作>中也介绍过基于POP3和S ...
- C#结合LumiSoft.Net.dll读取Outlook邮件(.eml格式邮件)
如果直接从Outlook(或者微软的其它邮件客户端如:Outlook Express.Windows Live Mail)的邮件文件(.eml格式)中提取各种电子邮件内容,使用LumiSoft.Net ...
- 使用C#和OpenPop.dll开发读取POP3邮件程序
制作一个ASP.NET MVC4论坛项目,该项目需要将以往十多年的Mail List(邮件列表)内容都导入到新的论坛中,因此需要能够将邮件的标题.发布时间.发布人及邮件内容导入到论坛的数据库内..Ne ...
- 基于Lumisoft.NET组件的SMTP账号登陆检测
在邮件处理的方面,Lumisoft.NET可以说是非常不错的一个选择,我在前面几篇文章中都介绍过这个组件. 基于Lumisoft.NET组件开发碰到乱码等一些问题的解决 基于Lumisoft.NET组 ...
- linux邮件客户端mutt日志文件,发不出邮件
linux上面使用很方便的收发邮件客户端(即MUA),还有一个是mail,大家也可以试试. 在网上找了很多,都说需要msmtp配合使用,其实mutt里面也内建了smtp支持的. mutt and SM ...
- 基于Lumisoft.NET组件的POP3邮件接收和删除操作(转载)
Lumisoft.NET组件是一个非常强大的邮件发送.邮件接收等功能的开源组件,一般用它来处理邮件的相关操作,是非常合适的.之前也写过一些该组件的随笔文章,不过主要是利用来发送邮件居多,最近由于项目需 ...
- 基于Lumisoft.NET组件的POP3邮件接收和删除操作
From: http://www.cnblogs.com/wuhuacong/archive/2013/05/06/3063093.html Lumisoft.NET组件是一个非常强大的邮件发送.邮件 ...
- C#- 基于Lumisoft.NET组件的POP3邮件接管和删除操纵
Lumisoft.NET组件是一个很是强大的邮件发送.邮件接管等功能的开源组件,一般用它来处理惩罚邮件的相干操纵,是很是合适的.之前也写过一些该组件的漫笔文章,不过主如果哄骗来发送邮件居多,比来因为项 ...
- 基于XC7Z100+AD9361的双收双发无线电射频板卡
一.板卡概述 板卡基于Xilinx公司的SoC架构(ARM+FPGA)的ZYNQ7100芯片和ADI公司高集成度的捷变射频收发器AD9361,实现频谱范围70MHz~6GHz,模拟带宽200KHz~5 ...
随机推荐
- 怎样在MyEclipse上耍Chrome
近期在忙着期末大作业,所以Windows App和算法的专栏都没有更了,随后这几天都会陆续開始更新的,欢迎大家的关注啦-- 在写期末大作业的时候遇到一个问题.一个新的特性在MyEclipse自带的浏览 ...
- 求好用的在线手册编写工具,能编写像bootstrap在线Doc那种的,想为OpenCenter写个在线手册
原文地址:http://www.oschina.net/question/1014458_225711 各位OSCer的开源项目的在线说明文档都是用什么写的呢? 类似 http://v3.bootcs ...
- IPHONE IOS6 模拟器没有HOME按键解决方法
替代home键的快捷键是 Cmd-Shift-H: 双击HOME键就是 Cmd-Shift-H 按两次: 参考:http://www.cnblogs.com/yingkong1987/archive/ ...
- 《学习opencv》笔记——矩阵和图像操作——cvInRange,cvInRangeS,cvInvert and cvMahalonobis
矩阵和图像的操作 (1)cvInRange函数 其结构 void cvInRange(//提取图像中在阈值中间的部分 const CvArr* src,//目标图像 const CvArr* lowe ...
- [活动已结束]《深入理解Android:Wi-Fi、NFC和GPS卷》CSDN社区活动
今天有一个CSDN社区活动,解答关于Android系统的学习.认识.开发等方面的问题,并就<深入理解Android:Wi-Fi.NFC和GPS卷>一书为大家答疑解惑,了解Android F ...
- linux 字符终端terminal下 ftp的配置和启用
1. ftp组件一般不是linux的自带组件,在ubuntu 12中,就自带了ftp组件 vsftp,而在redhat 9中,就没有自带需要从安装光盘中或下载相应的ftp的rpm包. ~$ sudo ...
- [翻译] Haneke(处理图片缓存问题)
Haneke https://github.com/hpique/Haneke A lightweight zero-config image cache for iOS. 轻量级0配置图片缓存. H ...
- leetcode笔记:Same Tree
一. 题目描写叙述 Given two binary trees, write a function to check if they are equal or not. Two binary tre ...
- Gradle for Android 翻译 -1
英文版电子书下载 参考:Gradle for Android 一.从 Gradle 和 AS 开始 [Getting Started with Gradle and Android Studio] ...
- TabLayout ViewPager Fragment 简介 案例 MD
Markdown版本笔记 我的GitHub首页 我的博客 我的微信 我的邮箱 MyAndroidBlogs baiqiantao baiqiantao bqt20094 baiqiantao@sina ...