private void SendMail()
{
MailMessage mailMsg = new
MailMessage();
mailMsg.To = tbToEmail.Text;
mailMsg.From =
tbEmail.Text;
mailMsg.Subject = tbTitle.Text;
mailMsg.Body =
tbContent.Text;
mailMsg.BodyFormat= MailFormat.Text ;
mailMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate",
"1");
mailMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername",tbSendName.Text);
mailMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword",tbSendPassword.Text);
// for(int i =
0;i<cblUpload.Items.Count;i++)
// {
// if(cblUpload.Items[i].Selected
== true)
// {
// attachPath =
@"e:\sun.net\sample\email\rsn\upload\" +
cblUpload.Items[i].Value;
// mailMsg.Attachments.Add(new
MailAttachment(attachPath)) ;
// }
// }
try
{
SmtpMail.SmtpServer =
tbSmtpServer.Text;
SmtpMail.Send(mailMsg);
success ++
;
}
catch
{
error ++ ;
}
}
原文地址:http://www.cnblogs.com/liupengfei19940119/p/3755744.html