C#中att = (OpenPOP.MIMEParser.Attachment)msg.Attachments[1]; 中最后面中括号里的1是什么意思?

huahua_asic 2009-12-24 10:06:36
c#编写的邮件接收中
OpenPOP.MIMEParser.Attachment att = null;
OpenPOP.MIMEParser.Message msg = null;
att = (OpenPOP.MIMEParser.Attachment)msg.Attachments[1];
其中第三句中最后面中括号的1代表的是什么意思?为什么不是0?
我想知道为什么不是0,这个数组里面有几个元素我也不清楚 因为我在运行的时候出错了 有个索引越界了 我不确定是不是这里
请各位高手指点~~~万分感激~
...全文
165 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
dqw120 2009-12-24
  • 打赏
  • 举报
回复
定义一个n,int n=1 or 2......;n是表示是第几封信,你可以用jpop.Count来循环取出所有的

Msg = jpop.Messages[3];--->Msg = jpop.Messages[n];

Msg.Attachments[i].SaveToFile("e:\\"+Msg.Attachments[i].Name);---->
Msg.Attachments[i].SaveToFile("e:\\"+Msg.Attachments[n].Name);
dqw120 2009-12-24
  • 打赏
  • 举报
回复
string f="";
//string strf="";
jmail.Message Msg=new jmail.Message();
jmail.POP3 jpop=new jmail.POP3();
try
{
jpop.Connect("shaokang99","4226521","pop3.163.com",110);
Count.Text=jpop.Count.ToString();
Msg = jpop.Messages[3];
Sendfrom.Text = Msg.FromName;
Subject.Text = Msg.Subject;
Datetime.Text = Msg.Date.ToString();
Body.Text = Msg.Body;
num.Text=Msg.Attachments.Count.ToString();
for(int i=0;i<Msg.Attachments.Count;i++)
{
f=f+Msg.Attachments[i].Name;
Msg.Attachments[i].SaveToFile("e:\\"+Msg.Attachments[i].Name);



}
name.Text=f;
jpop.Disconnect();
}
catch(Exception ex)
{
Count.Text=ex.Message.ToString();
}

111,123

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧