1
我要發送註冊電子郵件,提交表單後提交。我瀏覽過谷歌文檔,但我不明白是否有方法使用Google服務器發送。 如果可能的話,請給我一個代碼。 謝謝。ASP.NET通過Google發送電子郵件smtp
我要發送註冊電子郵件,提交表單後提交。我瀏覽過谷歌文檔,但我不明白是否有方法使用Google服務器發送。 如果可能的話,請給我一個代碼。 謝謝。ASP.NET通過Google發送電子郵件smtp
protected void btnSubmit_Click(object sender, EventArgs e)
{
try
{
MailMessage Msg = new MailMessage();
// Sender e-mail address.
Msg.From = txtFrom.Text;
// Recipient e-mail address.
Msg.To = txtTo.Text;
Msg.Subject = txtSubject.Text;
Msg.Body = txtBody.Text;
// your remote SMTP server IP.
SmtpMail.SmtpServer = "10.20.72.1";
SmtpMail.Send(Msg);
Msg = null;
Page.RegisterStartupScript("UserMsg", "<script>alert('Mail sent thank you...');if(alert){ window.location='SendMail.aspx';}</script>");
}
catch (Exception ex)
{
Console.WriteLine("{0} Exception caught.", ex);
}
}
您好,歡迎StackOverflow上。詢問前請閱讀http://stackoverflow.com/help。 – Marco
快速搜索Google會將其作爲第一次打擊:http://www.codeproject.com/Questions/254743/sending-email-in-asp-net-using-smtp-gmail-server – Abhitalks