如何在所需的电子邮件地址上发送电子邮件

如何在所需的电子邮件地址上发送电子邮件

本文介绍了如何在所需的电子邮件地址上发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞!using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;using System.ComponentModel;// for backgroundworker classusing System.Net;using System.Net.Mail;using System.Threading;namespace ProLogixPOS{ public partial class frmForgetPassword : System.Web.UI.Page { BackgroundWorker bw; public void SendMail() { MailMessage msg = new MailMessage(); msg.From = new MailAddress("[email protected]"); msg.To.Add("[email protected]"); msg.Body = "Testing the automatic mail"; msg.IsBodyHtml = true; msg.Subject = "Movie Data"; SmtpClient smt = new SmtpClient("smtp.gmail.com"); smt.Port = 25; smt.Credentials = new NetworkCredential("[email protected]", "123456789"); smt.EnableSsl = true; smt.UseDefaultCredentials = true; smt.Send(msg); string script = "<script>alert('Mail Sent Successfully');self.close();</script>"; this.ClientScript.RegisterClientScriptBlock(this.GetType(), "sendMail", script); } protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { SendMail(); } }}推荐答案WebMail.EnablSsl = true; ..然后继续。阅读文章,它有工作代码示例。您也可以测试它,并且它也解释了使用gmail帐户在ASP.NET中发送电子邮件的基本概念。..then you continue. Read the article, it has the working code sample. You can test it too, and also it has some explaination of the basic concepts of sending the emails in ASP.NET using gmail accounts. 这篇关于如何在所需的电子邮件地址上发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-12 13:00