title: c# asp.net call async method from static sync
body: <p>I call a static method named - <code>validSendPass</code> from ajax</p>
  
  <pre><code>[WebMethod]
  public static string validSendPass(string em)
  </code></pre>
  
  <p>In this method I need create email class and call to method that send async my email</p>
  
  <pre><code>classes.email ems = new classes.email();
  ems.sendPassword(myemail, my email name, user email, user name, password, "Your password", pas);
  </code></pre>
  
  <p>This method:</p>
  
  <pre><code>var fromAddress = new MailAddress(fromem, fromname);
  var toAddress = new MailAddress(toem, toname);
  
  var smtp = new SmtpClient
  {
      Host = "smtp.gmail.com",
      Port = 587,
      EnableSsl = true,
      DeliveryMethod = SmtpDeliveryMethod.Network,
      UseDefaultCredentials = false,
      Credentials = new NetworkCredential(fromAddress.Address, fromPassword),
      Timeout = 20000
  };
  using (var message = new MailMessage(fromAddress, toAddress)
  {
      Subject = subject,
      Body = body
  })
  {
      try { smtp.Send(message); }
      catch { }
  }
  </code></pre>
  
  <p>For this I replace smtp.Send to smtp.SendMailAsync or to smtp SendAsync, add the async.</p>
  
  <p>How I need change this code - call async method from static method?</p>