Advertisement
Guest User

Untitled

a guest
Jul 21st, 2016
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. namespace SendSmsMessage
  2. {
  3. public partial class Form1 : Form
  4. {
  5. public Form1()
  6. {
  7. InitializeComponent();
  8. }
  9.  
  10. private void btnSend_Click(object sender, EventArgs e)
  11. {
  12. using (System.Net.WebClient client = new System.Net.WebClient()
  13. {
  14. try
  15. {
  16. string url = "http://smsc.vianett.no/v3/send.ashx?" +
  17. "src=" + txtPhoneNumber.Text + "&" +
  18. "dst=" + txtPhoneNumber.Text + "&" +
  19. "msg="System.Web.HttpUtility.UrlEncode(txtMessage.Text, System.Text.Encoding.GetEncoding("ISO-8859-1")) + "" +
  20. "username=" + System.Web.HttpUtility.UrlEncode(txtUsername.Text + "&" +
  21. "password=" + System.Web.HttpUtility.UrlEncode(txtPassword.Text);
  22. string result = client.DownloadString(url);
  23. if (result.Contains("OK"))
  24. MessageBox.Show("Tvoje zprava byla uspesne odeslana.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
  25. else
  26. MessageBox.Show("Chyba: Zpravu nebylo mozne odeslat", MessageBoxButtons.OK, MessageBoxIcon.Information);
  27. }
  28. catch (Exception ex)
  29. {
  30. MessageBox.Show(ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
  31. }
  32. }
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement