使用托管邮件发送电子邮件

时间:2017-08-24 13:33:51

标签: c# smtp gmail

当我使用此代码时,我正尝试从公司邮件发送电子邮件 我得到了   public String SendMail(String Email)         {

        try
        {
            var client = new SmtpClient("smtp.gmail.com",587)
            {
                Credentials = new System.Net.NetworkCredential("************@itsans.com", "*********"),
                EnableSsl = true
            };
           // client.UseDefaultCredentials = false;
            String VerCode = CreateRandomCode(4);

            AppUserBusiness appuser = new AppUserBusiness();
            String InsertVer = appuser.ForgotPassword(Email, VerCode);

            if (InsertVer == "Done")
                client.Send("*********@itsans.com", Email, "iBlink Verification", "Your Verification Code is :" + VerCode);

            return InsertVer;
        }
        catch (Exception Ex)
        {

            Logging.WriteToFile(Ex.Message, Ex.StackTrace);
            return "Fail";
        }

    }

{“无法连接到远程服务器”}

{“连接尝试失败,因为连接方在一段时间后没有正确响应,或者建立的连接失败,因为连接的主机无法响应72.167.238.29:587”}

0 个答案:

没有答案