jeudi 28 avril 2016

Mail not sending in mvc 3

i have posted my source that having porblem named

A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond

i have implemented by ref of

please help me to solve this issue

thanks in advance :)

View Page

 @using (Html.BeginForm("Emailto", "Home", FormMethod.Post))
@Html.TextBoxFor(a => a.Position, new { @readonly = "readonly", @id = "Position", @name = "Position" })
  <input type="text" value="" id="txtname" name="txtname" required />
  <input type="email" value="" id="txtemail" name="fromEmail"  required />
<input type="submit" id="btnApply" name="btnApply" value="Apply" />


[HttpPost, ValidateInput(false)]
        public ActionResult Emailto(string Position, string txtname, string fromEmail)

            EmailManager.SendMessage(Position, txtname, fromEmail);
            return Redirect("Index");


        public static void SendMessage(string Position, string txtname, string fromEmail)
            const string SERVER = "";
            const string TOEMAIL = "";
            MailAddress from = new MailAddress(fromEmail);
            MailAddress to = new MailAddress(TOEMAIL);
            MailMessage message = new MailMessage(from, to);

            message.Subject = "Position " + Position;
            message.Body = "Message from: " + Position + " at " +
                           fromEmail + "\n\n" + txtname;
            message.IsBodyHtml = false;
            SmtpClient client = new SmtpClient(SERVER);

Aucun commentaire:

Enregistrer un commentaire