using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using jmail;public partial class aa_Default5 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{ }
protected void Button1_Click(object sender, EventArgs e)
{
/**/
///建立收邮件对象
POP3Class popMail = new POP3Class();
//运行这句出现错误 错误信息:检索 COM 类工厂中 CLSID 为 {F812B147-0E26-4222-8EE4-9F753CD2B39C} 的组件时失败,原因是出现以下错误: 8004015 用户未处理COMException /**/
///建立邮件信息接口
jmail.Message mailMessage; /**/
///建立附件集接口
jmail.Attachments atts; /**/
///建立附件接口
jmail.Attachment att;
try
{
popMail.Connect("[email protected]", "qwertyu", "pop3.163.com",110);
if (0 < popMail.Count)
{
/**/
///根据取到的邮件数量依次取得每封邮件
for (int i = 1; i <= popMail.Count; i++)
{
/**/
///取得一条邮件信息
mailMessage = popMail.Messages[i]; /**/
///取得该邮件的附件集合
atts = mailMessage.Attachments; /**/
///设置邮件的编码方式
mailMessage.Charset = "GB2312"; /**/
///设置邮件的附件编码方式
mailMessage.Encoding = "Base64"; /**/
///是否将信头编码成iso-8859-1字符集
mailMessage.ISOEncodeHeaders = false; /**/
///邮件的优先级
// txtpriority.Text = mailMessage.Priority.ToString(); /**/
///邮件的发送人的信箱地址
TextBox1.Text = mailMessage.From; /**/
///邮件的发送人
TextBox2.Text = mailMessage.FromName; /**/
///邮件主题
TextBox3.Text = mailMessage.Subject; /**/
///邮件内容
TextBox4.Text = mailMessage.Body; /**/
///邮件大小
TextBox5.Text = mailMessage.Size.ToString(); for (int j = 0; j < atts.Count; j++)
{
/**/
///取得附件
att = atts[j]; /**/
///附件名称
string attname = att.Name; /**/
///上传到服务器
att.SaveToFile("f:\\attFile\\" + attname); } }
// panMailInfo.Visible = true;
att = null;
atts = null;
}
else
{
Response.Write("没有新邮件!"); }
popMail.DeleteMessages();
popMail.Disconnect();
popMail = null;
}
catch
{
Response.Write("Warning!请检查邮件服务器的设置是否正确!");
}
}
}
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using jmail;public partial class aa_Default5 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{ }
protected void Button1_Click(object sender, EventArgs e)
{
/**/
///建立收邮件对象
POP3Class popMail = new POP3Class();
//运行这句出现错误 错误信息:检索 COM 类工厂中 CLSID 为 {F812B147-0E26-4222-8EE4-9F753CD2B39C} 的组件时失败,原因是出现以下错误: 8004015 用户未处理COMException /**/
///建立邮件信息接口
jmail.Message mailMessage; /**/
///建立附件集接口
jmail.Attachments atts; /**/
///建立附件接口
jmail.Attachment att;
try
{
popMail.Connect("[email protected]", "qwertyu", "pop3.163.com",110);
if (0 < popMail.Count)
{
/**/
///根据取到的邮件数量依次取得每封邮件
for (int i = 1; i <= popMail.Count; i++)
{
/**/
///取得一条邮件信息
mailMessage = popMail.Messages[i]; /**/
///取得该邮件的附件集合
atts = mailMessage.Attachments; /**/
///设置邮件的编码方式
mailMessage.Charset = "GB2312"; /**/
///设置邮件的附件编码方式
mailMessage.Encoding = "Base64"; /**/
///是否将信头编码成iso-8859-1字符集
mailMessage.ISOEncodeHeaders = false; /**/
///邮件的优先级
// txtpriority.Text = mailMessage.Priority.ToString(); /**/
///邮件的发送人的信箱地址
TextBox1.Text = mailMessage.From; /**/
///邮件的发送人
TextBox2.Text = mailMessage.FromName; /**/
///邮件主题
TextBox3.Text = mailMessage.Subject; /**/
///邮件内容
TextBox4.Text = mailMessage.Body; /**/
///邮件大小
TextBox5.Text = mailMessage.Size.ToString(); for (int j = 0; j < atts.Count; j++)
{
/**/
///取得附件
att = atts[j]; /**/
///附件名称
string attname = att.Name; /**/
///上传到服务器
att.SaveToFile("f:\\attFile\\" + attname); } }
// panMailInfo.Visible = true;
att = null;
atts = null;
}
else
{
Response.Write("没有新邮件!"); }
popMail.DeleteMessages();
popMail.Disconnect();
popMail = null;
}
catch
{
Response.Write("Warning!请检查邮件服务器的设置是否正确!");
}
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货