//// <summary>
/// 邮件发送方法(带附件)
/// </summary>
/// <param name="mailto">收件人地址。如:receiver@jb200.com</param>
/// <param name="mailsubject">邮件标题</param>
/// <param name="mailbody">邮件正文</param>
/// <param name="mailFrom">邮件发送人地址。如:sender@jb200.com</param>
/// <param name="list">附件路径</param>
/// <returns></returns>
public bool My
sendmail(string mailto, string mailsubject, string mailbody, string mailFrom, ArrayList list)
{
try
{
//邮件发送人地址
System.Net.Mail.MailAddress from = new System.Net.Mail.MailAddress(mailFrom);
//如test@jb200.com,初步测试,用test@sina.com不行,用163的邮件
服务器,就必须用163邮箱的用户名
//收件人地址
System.Net.Mail.MailAddress to = new System.Net.Mail.MailAddress(mailto);//如test@tom.com
System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage(from, to);
mail.Subject = mailsubject;
mail.Body = mailbody;
//设置服务器
System.Net.Mail.SmtpClient mySmth = new System.Net.Mail.SmtpClient();
//增加附件
int count = list.Count;
for (int i = 0; i < count; i++)
{
System.Net.Mail.Attachment data = new System.Net.Mail.Attachment(list[i].ToString());
mail.Attachments.Add(data);
}
mySmth.Send(mail);
mail.Dispose();
return true;
}
catch
{
return false;
}
}