Ejemplo n.º 1
0
        public userForm(User sender)
        {
            InitializeComponent();

            this.sender = sender;

            textBoxLastName.Text = sender.LastName;
            textBoxFirstName.Text = sender.FirstName;
            textBoxEmail.Text = sender.Email;
            textBoxPassword.Text = sender.Password;
            comboBoxProviders.Text = sender.EmailService;
        }
Ejemplo n.º 2
0
        public Form1()
        {
            InitializeComponent();
            loadContacts();

            comboBoxTemplate.SelectedIndex = 0;
            buttonRemove.Enabled = false;

            //sets up a dummy user
            currentUser = new User("Burgundy", "Ron", "*****@*****.**", "***");
            currentUser.EmailService = "Gmail";
        }
        public static string generateHTMLForSending(User sender, Contact receiver, string message, string html, int template)
        {
            string[] tokens;
            string ret = html;
            string from, to;
            string temp = "";
            int tokenNum, tokenBreaks, j;

            from = sender.FirstName + " " + sender.LastName;
            to = receiver.FirstName + " " + receiver.LastName;

            ret = ret.Replace("#from#", from);
            ret = ret.Replace("#name#", to);

            tokens = message.Split(' ');
            tokenNum = tokens.Length;
            tokenBreaks = tokenNum / 10;

            if (template == 1)
            {
                ret = ret.Replace("1.jpg", "cid:1");

                temp += tokens[0] + " ";
                j = 1;

                for (int i = 1; i < tokenNum; i++)
                {
                    temp += tokens[i] + " ";

                    if (j == 10)
                    {
                        temp += "<br>";
                        j = 0;
                    }

                    j++;
                }
            }

            else
            {
                ret = ret.Replace("2.jpg", "cid:2");
                temp = message;
            }

            ret = ret.Replace("#body#", temp);

            return ret;
        }
        public GmailManager(User theSender, List<Contact> contacts, string subject, string body, int img)
        {
            this.body = body;
            this.fromName = theSender.FirstName + " " + theSender.LastName;
            this.fromAddress = theSender.Email;
            this.fromPassword = theSender.Password;
            this.contacts = contacts;
            this.subject = subject;
            this.body = body;
            this.theSender = theSender;
            this.img = img;

            smtp = new SmtpClient();

            authenticate();
        }
Ejemplo n.º 5
0
 private void buttonCancel_Click(object sender, EventArgs e)
 {
     this.sender = null;
 }
Ejemplo n.º 6
0
        private void initUser()
        {
            User newUser = new User();

            if (currentUser == null)
                currentUser = new User();

            userForm userForm = new userForm(currentUser);

            userForm.ShowDialog();
            newUser = userForm.User;

            if (newUser == null)
                MessageBox.Show("User was not initialized correctly.");

            else
            {
                labelUsernameout.Text = currentUser.FirstName + " " + currentUser.LastName;
                labelEmailout2.Text = currentUser.Email;
                buttonSend.Enabled = true;
            }
        }
Ejemplo n.º 7
0
        private void buttonPreview_Click_1(object sender, EventArgs e)
        {
            string preview = "";
            int img = 1;
            User testu;
            Contact testc;
            StreamWriter fout;

            if (comboBoxTemplate.Text == "RedTemplate.jpg")
            {
                img = 1;
                preview = HolidayMailer.Properties.Resources.index1;
            }

            if (comboBoxTemplate.Text == "RedAndBlackTemplate.jpg")
            {
                img = 2;
                preview = HolidayMailer.Properties.Resources.index2;
            }

            if (currentUser == null)
                testu = new User("Nimoy", "Leonard", "*****@*****.**", "garbage");

            else
                testu = currentUser;

            testc = new Contact("Shatner", "William", "*****@*****.**", false);

            preview = HTMLManager.generateHTMLForPreviewing(testu, testc, textBoxCustomMessage.Text, preview, img);

            fout = new StreamWriter("HTMLPreview.html");

            fout.Write(preview);

            if (img == 1)
                HolidayMailer.Properties.Resources.img1.Save(img + ".jpg");

            if (img == 2)
                HolidayMailer.Properties.Resources.img2.Save(img + ".jpg");

            System.Diagnostics.Process.Start("HTMLPreview.html");

            fout.Close();
        }