title: How to send sms using whatsapp API and winform C#?
body: <p>I write the code to send sms using whatsapp API and winform C#.  I don't know what problem with it. </p>
  
  <p>It has error </p>
  
  <blockquote>
    <p>"Login failed not-authorized"</p>
  </blockquote>
  
  <p>...but I registered in "Whatsapp  registration" download from "<a href="https://github.com/mgp25/WART" rel="nofollow noreferrer">https://github.com/mgp25/WART</a>" and have password like image.</p>
  
  <p>Here is my code</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.ComponentModel;
  using System.Data;
  using System.Drawing;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  using System.Windows.Forms;
  using WhatsAppApi;
  
  namespace sms
  {
      public partial class Form1 : Form
      {
          public Form1()
          {
              InitializeComponent();
          }
  
      private void btn_send_Click(object sender, EventArgs e)
      {
          WhatsApp wa = new WhatsApp(txt_phone.Text, txt_pass.Text, txt_name.Text, true);
          wa.OnConnectSuccess+= () =&gt;
              {
                  txt_status.Text = "Connect...";
                  wa.OnLoginSuccess+= (phone, data) =&gt;
                      {
                          txt_status.Text += "\r\nConnection success!";
                          wa.SendMessage(txt_to.Text, txt_message.Text);
                          txt_status.Text += "\r\nMessage Sent!";
                      };
                  wa.OnLoginFailed+= (data) =&gt;
                      {
                          txt_status.Text += string.Format("\r\bLogin failed {0}", data);
                      };
                  wa.Login();
              };
          wa.OnConnectFailed+= (ex) =&gt;
              {
                  txt_status.Text += string.Format("\r\bConnect failed {0}", ex.StackTrace);
              };
          wa.Connect();
      }
  }
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/CMUcy.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CMUcy.jpg" alt="App"></a></p>