title: C# code for sending email in mvc4 doubts
body: <p>am am doing a website in mvc4 using c#. currently i test this in localhost. I want to send passwords to registering persons email. i use the following code.</p>
  
  <p>//model</p>
  
  <pre><code> public void SendPasswordToMail(string newpwd,string email)
      {
          string mailcontent ="Your password is "+ newpwd;
          string toemail = email.Trim();
          try
          {
              MailMessage mail = new MailMessage();
              SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");
              mail.From = new MailAddress("paru.mr@gmail.com");
              mail.To.Add(toemail);
              mail.Subject = "Your New Password";
              mail.Body = mailcontent;
              //Attachment attachment = new Attachment(filename);
              //mail.Attachments.Add(attachment);
              SmtpServer.Port = 25;
              SmtpServer.Credentials = new System.Net.NetworkCredential("me", "password");  //is that NetworkCredential
              SmtpServer.EnableSsl = true;
              SmtpServer.Send(mail);
  
          }
          catch (Exception e)
          {
              throw e;
          }
      }
  </code></pre>
  
  <p>//controller</p>
  
  <pre><code>  string newpwd;
      [HttpPost]
      public ActionResult SendPassword(int Id,string email)
      {
          bool IsMember=CheckMember(Id);
          if (IsMember == true)
          {
               newpwd = new Member().RandomPaswordGen();
          }
         .......//here i want to call that model
          return View();
      }
  </code></pre>
  
  <p>Is the model is right or not. and what should be the return type of this model(now it is void and i dont know how this call in controller). and how to get default NetworkCredential. Please help me</p>