读书人

制造客户端邮件发送系统(winform版)

发布时间: 2013-01-20 10:22:40 作者: rapoo

制作客户端邮件发送系统(winform版)

--------Form1后台-------------------
private void btnSend_Click(object sender, EventArgs e)
{
MailMessage msg = new MailMessage();
msg.Body = this.txtBody.Text;
msg.Subject = this.txtSubject.Text;

msg.From = new MailAddress("邮箱详细账号");
msg.To.Add(this.txtMailAddress.Text);
msg.IsBodyHtml = true;

SmtpClient client = new SmtpClient();
client.Host = "smtp.qq.com";
client.Port = 25;

NetworkCredential credetial = new NetworkCredential();
credetial.UserName = "@之前的部分";
credetial.Password = "邮箱密码";
client.Credentials = credetial;
Attachment att = new Attachment(this.txtFuJian.Text);
msg.Attachments.Add(att);
client.Send(msg);
MessageBox.Show("邮件发送成功");
}

private void btnTianJia_Click(object sender, EventArgs e)
{
if (this.openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
this.txtFuJian.Text = this.openFileDialog1.FileName;
}
}

读书人网 >移动开发

热点推荐