电子邮件配置

时间:2017-07-29 17:28:40

标签: c# smtp gmail

大家好,我是第一次做电子邮件功能,我搜索了如何发送电子邮件

&.next {
  background-color: $transparent;
  background-image: url('images/arrow.svg');
  background-position: center;
  background-repeat: no-repeat;
  height: 1em;
  margin-left: .5em;
  -moz-transform: scaleX(-1);
  -o-transform: scaleX(-1);
  -webkit-transform: scaleX(-1);
  transform: scaleX(-1);
  filter: FlipH;
  -ms-filter: "FlipH";
}

&.prev {
  background-color: $transparent;
  background-image: url('images/arrow.svg');
  background-position: center;
  background-repeat: no-repeat;
  height: 1em;
  margin-right: .5em;
}

我试过运行这个,但我不确定是什么问题...我没有使用IIS或其他任何东西

(更新) 我在这个网站上传了错误图片 http://imgur.com/3vVZhsW

1 个答案:

答案 0 :(得分:0)

这个会帮助你..!试试这个......!

try
{
                MailMessage Msg = new MailMessage();
                // Sender e-mail address.

                SmtpClient smtp = new SmtpClient();
                //smtp object.        

                Msg.From = new MailAddress("from@gmail.com");
                // Recipient e-mail address.

                Msg.To.Add(to@gmail.com);
                //here you can pass textbox value how need to send mail.

                Msg.Subject = "Please confirm your subscription";
                Msg.Body = "<body></body>";


                Msg.IsBodyHtml = true;
                // your remote SMTP server IP.

                smtp.Host = "smtp.gmail.com";
                smtp.Port = 587;
                smtp.Credentials = new System.Net.NetworkCredential("from@gmail.com", "password");
                smtp.EnableSsl = true;
                smtp.Send(Msg);
                //Msg = null;
}
catch(Exception ex)
{
    Message.Show("Error:" + ex.Message);
}