我可能错了,但我遇到了问题...... 我想在没有密码的情况下使用ASP.net将电子邮件发送给用户 这是我的代码
但我没有密码。如何在没有密码的情况下向用户发送电子邮件。
protected void submit_Click(object sender, Event Args e)
{
MailMessage mail = new MailMessage();
mail.To.Add(txtTo. Text);
mail.From = new Mail Address(txt_from.Text);
mail.Subject = txtSubject. Text;
mail.Body = txtBody.Text;
mail.IsBodyHtml = true;
if (fileUpload1.HasFile)
{
mail.Attachments.Add(new Attachment(fileUpload1.PostedFile.InputStream, fileUpload1.FileName));
}
SmtpClient smtp = new SmtpClient();
smtp.Host = "mysmtp.gmail.com"; //Or Your SMTP Server Address
smtp.Credentials = new System.Net.NetworkCredential("email", "password");
//Or your Smtp Email ID and Password
smtp.EnableSsl = true;
smtp.Send(mail);
}