private void sengmill_net()
{//.net smtp类进行邮件发送,支持认证,附件添加;
System.Web.Mail.MailMessage mailmsg = new System.Web.Mail.MailMessage();
mailmsg.From = Jack
mailmsg.To = Jimmy;
mailmsg.Body = this.tb_mailBody.Text.Trim();
mailmsg.Subject = "test mail from hz";
/* 附件的粘贴, ^_^,笨了点;
if(this.att1.Value.ToString().Trim()!=string.Empty)
mailmsg.Attachments.Add(new System.Web.Mail.MailAttachment(this.att1.Value.ToString().Trim()));
if(this.att2.Value.ToString().Trim()!=string.Empty)
mailmsg.Attachments.Add(new System.Web.Mail.MailAttachment(this.att2.Value.ToString().Trim()));
if(this.att3.Value.ToString().Trim()!=string.Empty)
mailmsg.Attachments.Add(new System.Web.Mail.MailAttachment(this.att3.Value.ToString().Trim()));
*/
mailmsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
//是否需要验证,一般是要的
mailmsg.Fields.Add
("http://schemas.microsoft.com/cdo/configuration/sendusername", " Jack ");
//自己邮箱的用户名
mailmsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", " 123
");
//自己邮箱的密码
System.Web.Mail.SmtpMail.SmtpServer = " 192.168.0.25 "
System.Web.Mail.SmtpMail.Send(mailmsg);
}
{//.net smtp类进行邮件发送,支持认证,附件添加;
System.Web.Mail.MailMessage mailmsg = new System.Web.Mail.MailMessage();
mailmsg.From = Jack
mailmsg.To = Jimmy;
mailmsg.Body = this.tb_mailBody.Text.Trim();
mailmsg.Subject = "test mail from hz";
/* 附件的粘贴, ^_^,笨了点;
if(this.att1.Value.ToString().Trim()!=string.Empty)
mailmsg.Attachments.Add(new System.Web.Mail.MailAttachment(this.att1.Value.ToString().Trim()));
if(this.att2.Value.ToString().Trim()!=string.Empty)
mailmsg.Attachments.Add(new System.Web.Mail.MailAttachment(this.att2.Value.ToString().Trim()));
if(this.att3.Value.ToString().Trim()!=string.Empty)
mailmsg.Attachments.Add(new System.Web.Mail.MailAttachment(this.att3.Value.ToString().Trim()));
*/
mailmsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
//是否需要验证,一般是要的
mailmsg.Fields.Add
("http://schemas.microsoft.com/cdo/configuration/sendusername", " Jack ");
//自己邮箱的用户名
mailmsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", " 123
");
//自己邮箱的密码
System.Web.Mail.SmtpMail.SmtpServer = " 192.168.0.25 "
System.Web.Mail.SmtpMail.Send(mailmsg);
}
{//.net smtp类进行邮件发送,支持认证,附件添加;
System.Web.Mail.MailMessage mailmsg = new System.Web.Mail.MailMessage();
mailmsg.From = "192.168.0.25 ";
mailmsg.To = "Jimmy";
mailmsg.Body = this.tb_mailBody.Text.Trim();
mailmsg.Subject = "test mail from hz";
/* 附件的粘贴, ^_^,笨了点;
if(this.att1.Value.ToString().Trim()!=string.Empty)
mailmsg.Attachments.Add(new System.Web.Mail.MailAttachment(this.att1.Value.ToString().Trim()));
if(this.att2.Value.ToString().Trim()!=string.Empty)
mailmsg.Attachments.Add(new System.Web.Mail.MailAttachment(this.att2.Value.ToString().Trim()));
if(this.att3.Value.ToString().Trim()!=string.Empty)
mailmsg.Attachments.Add(new System.Web.Mail.MailAttachment(this.att3.Value.ToString().Trim()));
*/
mailmsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
//是否需要验证,一般是要的
mailmsg.Fields.Add
("http://schemas.microsoft.com/cdo/configuration/sendusername", "Jack");
//自己邮箱的用户名
mailmsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "123");
//自己邮箱的密码
System.Web.Mail.SmtpMail.SmtpServer = this.tb_smtpserver.Text.Trim();
System.Web.Mail.SmtpMail.Send(mailmsg);
}
System.Net.Mail.MailMessage mail = new MailMessage();
mail.From = new MailAddress("####@####");//发件人的邮箱
mail.To.Add("Jimmy") ;//收件人的邮箱
mail.Subject = "111";//邮件主题
mail.Body = "22222";//邮件正文
mail.IsBodyHtml = true;
System.Net.Mail.Attachment mailAttachment = new Attachment(@"D:\新建 文本文档.txt");//邮件附件
mail.Attachments.Add(mailAttachment);
SmtpClient c = new SmtpClient();
//验证
c.Host = "192.168.0.25";
c.UseDefaultCredentials = false;
c.Credentials = new System.Net.NetworkCredential("Jack","123 ");
c.DeliveryMethod = SmtpDeliveryMethod.Network;
c.Send(mail);我原来写的,改了一下,你试试.根据你的要求再修改一下