标签:color 服务 form work 支持 efault 案例 size oid
调用QQ_Mail发送邮件
代码案例:
private void button1_Click(object sender, EventArgs e) { string myMaillAdress = ""; string myMaillPassword = ""; string myMaillMessage = ""; string toMaillAdress = ""; QQEmail qq_mial = new QQEmail(); bool send_status = qq_mial.IsSendEmail(myMaillAdress, toMaillAdress, myMaillMessage, myMaillPassword); } class QQEmail { public bool IsSendEmail(string FromAddress, string ToAddress, string Message, string Pwd) { MailAddress Address = new MailAddress(FromAddress); MailMessage mail = new MailMessage(); mail.SubjectEncoding = System.Text.Encoding.UTF8; mail.Subject = "这是" + FromAddress + "发送的一段信息:"; mail.BodyEncoding = System.Text.Encoding.UTF8; mail.Body = Message; mail.IsBodyHtml = true; mail.Priority = System.Net.Mail.MailPriority.Low; mail.To.Add(ToAddress); mail.From = Address; SmtpClient smtp = new SmtpClient("smtp.qq.com", 25);//smtp支持的服务器是smtp.qq.com,服务器端口是25,587也行 smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network; smtp.EnableSsl = true; smtp.UseDefaultCredentials = false; smtp.Credentials = new System.Net.NetworkCredential(FromAddress, Pwd);//切记这两个数据一定要填对 try { smtp.Send(mail); return true; } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message); return false; } } }
标签:color 服务 form work 支持 efault 案例 size oid
原文地址:https://www.cnblogs.com/wml-it/p/14814297.html