Savita Joshi

Savita Joshi

  • NA
  • 129
  • 132.6k

Error:The SMTP host was not specified.

Jun 17 2011 2:27 AM
Hi,

Plzz check this code and tell me where i am going wrong.. Code given below:

 public void sendemail( string email)
    {
        string EMAILID = email;
        string EMAILBODY;
        MailMessage objemail = new MailMessage();
        objemail.To.Add(new MailAddress(email));
        objemail.From = new MailAddress("[email protected]");
        objemail.Subject = "Password recovery";
        EMAILBODY = "<html>";
        EMAILBODY += "<Body>";
        EMAILBODY += "<table width=30%; cellpadding=5; border=0; align=centre;bgcolor=#f1fff9>";
        EMAILBODY += "<tr><td colspan=2 align=center bgcolor=#dff6d2><b>User Credentials:</b></td></tr>";
        EMAILBODY += "<tr><td>User:</td>";
        EMAILBODY += "<td align=left>"+userid+"</td></tr>";
        EMAILBODY += "<tr><td>Click the link to reset your password:</td>";
        EMAILBODY += "<td><a href='www.domainname.com'>Reset password</a></td></tr>";
        EMAILBODY += "<Body>";
        EMAILBODY += "</table>";
        EMAILBODY = "<html>";
        objemail.Body = EMAILBODY;
        objemail.Priority = MailPriority.High;
        objemail.IsBodyHtml = true;

        SmtpClient smtpmail = new SmtpClient();
        smtpmail.Send(objemail);
    }


Answers (3)