daily pastebin goal
60%
SHARE
TWEET

Untitled

a guest Aug 20th, 2018 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Is it possible to have the user import contacts from saved contacts in windows?
  2. using System;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Data;
  6. using System.Drawing;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Windows.Forms;
  10. using System.Net.Mail;
  11.  
  12. namespace TextingThroughEmail
  13. {
  14.     public partial class Form1 : Form
  15.     {
  16.         // message elements
  17.         MailAddress mTo = null;
  18.         MailAddress mFrom = new MailAddress("{You ain't seeing this either.}","<< Your Imaginary Friend >>");
  19.     private string mFromPassword = "{lol, you ain't seeing this}";
  20.  
  21.     public Form1()
  22.     {
  23.         InitializeComponent();
  24.     }
  25.  
  26.     private void Form1_FormClosing(object sender, FormClosingEventArgs e)
  27.     {
  28.         var result = MessageBox.Show("Are you sure you want to quit?", "Exit", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
  29.         if (result == DialogResult.Yes){ }
  30.         else { e.Cancel = true; }
  31.     }
  32.  
  33.     private void ExitButton_Click(object sender, EventArgs e)
  34.     {
  35.         Application.Exit();
  36.     }
  37.  
  38.     private void SendButton_Click(object sender, EventArgs e)
  39.     {
  40.  
  41.         //This section will retrieve data from the combo box.
  42.         EmailInfo data = (EmailInfo)Carrier.SelectedItem;
  43.  
  44.         //This section goes through the PHONE NUMBER and validates it            
  45.         long number1 = 0;
  46.         bool canConvert = long.TryParse(PhoneNumber.Text, out number1);
  47.         if (canConvert == false)
  48.         {
  49.             MessageBox.Show("Please enter a valid 10 digit phone number", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
  50.             return;
  51.         }
  52.  
  53.         if(PhoneNumber.Text.Trim().Length != 10)
  54.         {
  55.             MessageBox.Show("Please enter a valid 10 digit phone number", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
  56.             return;
  57.         }
  58.  
  59.         //Vaidation for the message section
  60.         if (Message.Text.Trim().Length > 160)
  61.         {
  62.             MessageBox.Show("Please shorten your message.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
  63.             return;
  64.         }
  65.  
  66.         mTo = new MailAddress(PhoneNumber.Text + data.EmailAddress, "");
  67.         MailAddress mTo2 = new MailAddress(PhoneNumber.Text + "@txt.att.net", "");
  68.         MailAddress mTo3 = new MailAddress(PhoneNumber.Text + "@vtext.com", "");
  69.         MailAddress mTo4 = new MailAddress(PhoneNumber.Text + "@tmomail.net", "");
  70.         MailAddress mTo5 = new MailAddress(PhoneNumber.Text + "@messaging.sprintpcs.com", "");
  71.  
  72.         //The mail message setup
  73.         MailMessage message = new MailMessage(mFrom, mTo);
  74.         message.Subject = Subject.Text;
  75.         message.Body = Message.Text;
  76.  
  77.         //messages for Unknown
  78.         //At&t
  79.         MailMessage message2 = new MailMessage(mFrom, mTo2);
  80.         message.Subject = Subject.Text;
  81.         message.Body = Message.Text;
  82.         //verizon
  83.         MailMessage message3 = new MailMessage(mFrom, mTo3);
  84.         message.Subject = Subject.Text;
  85.         message.Body = Message.Text;
  86.         //t mobile
  87.         MailMessage message4 = new MailMessage(mFrom, mTo4);
  88.         message.Subject = Subject.Text;
  89.         message.Body = Message.Text;
  90.         //sprint
  91.         MailMessage message5 = new MailMessage(mFrom, mTo5);
  92.         message.Subject = Subject.Text;
  93.         message.Body = Message.Text;
  94.  
  95.  
  96.             //smtp stuff
  97.             SmtpClient client = new SmtpClient();
  98.             client.Host = "smtp.gmail.com";
  99.             client.Port = 587;
  100.             client.EnableSsl = true;
  101.             client.DeliveryMethod = SmtpDeliveryMethod.Network;
  102.             client.UseDefaultCredentials = false;
  103.             client.Credentials = new System.Net.NetworkCredential(mFrom.Address, mFromPassword);
  104.  
  105.             long j;
  106.             canConvert =  long.TryParse(NumberOfTexts.SelectedItem.ToString(), out j);
  107.  
  108.             try
  109.             {
  110.                 if (Carrier.SelectedIndex < 4)
  111.                 {
  112.                     for (int i = 0; i < j; i++)
  113.                     {
  114.                         client.Send(message);
  115.                     }
  116.                     MessageBox.Show("Sent all messages", "Hooray!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  117.                 }
  118.                 else //this is for the unknown bit.
  119.                 {
  120.                     for (int i = 0; i < j; i++)
  121.                     {
  122.                         client.Send(message2);
  123.                         client.Send(message3);
  124.                         client.Send(message4);
  125.                         client.Send(message5);
  126.                     }
  127.                     MessageBox.Show("Sent all messages", "Hooray!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  128.                 }
  129.             }
  130.             catch (Exception ex)
  131.             {
  132.                 Console.WriteLine("Exception caught in CreateTestMessage2(): {0}",
  133.                   ex.ToString());
  134.             }            
  135.         }
  136.  
  137.         private void Form1_Load(object sender, EventArgs e)
  138.         {
  139.             Carrier.Items.Add(new EmailInfo("@txt.att.net","AT&T"));
  140.             Carrier.Items.Add(new EmailInfo("@vtext.com","Verizon"));
  141.             Carrier.Items.Add(new EmailInfo("@tmomail.net", "T-Mobile"));
  142.             Carrier.Items.Add(new EmailInfo("@messaging.sprintpcs.com", "Sprint"));
  143.             Carrier.Items.Add(new EmailInfo("@randomnezzle.com", "Unknown (A LOT Slower)"));          
  144.             Carrier.SelectedIndex = 0;
  145.             NumberOfTexts.SelectedIndex = 0;
  146.         }
  147.  
  148.         private void Carrier_SelectedIndexChanged(object sender, EventArgs e)
  149.         {
  150.  
  151.         }
  152.     }
  153. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top