Ejemplo n.º 1
0
        private void buttonDelete_Click(object sender, EventArgs e)
        {
            MailWindowMessageBox Message = new MailWindowMessageBox();

            Message.Text = "Deleted mail won't be send!";
            Message.Show();
            File.Delete(this.path);
            this.Close();
        }
Ejemplo n.º 2
0
        private void buttonDelete_Click(object sender, EventArgs e)
        {
            MailWindowMessageBox Message = new MailWindowMessageBox();

            /*  TO USE WHEN LEARN HOW TO ENCODE GOOGLE EVENT ID
             * File.Delete(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\" + name + ".mevent");
             * /// DELETE EVENT FROM GOOGLE CALENDAR
             *
             * string[] Scopes = { CalendarService.Scope.Calendar };
             * string ApplicationName = "MyCalendar Google Calendar API";
             *
             *
             * UserCredential credential;
             *
             * using (var stream =
             *  new FileStream("credentials.json", FileMode.Open, FileAccess.Read))
             * {
             *  // The file token.json stores the user's access and refresh tokens, and is created
             *  // automatically when the authorization flow completes for the first time.
             *  string credPath = "token.json";
             *  credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
             *      GoogleClientSecrets.Load(stream).Secrets,
             *      Scopes,
             *      "user",
             *      CancellationToken.None,
             *      new FileDataStore(credPath, true)).Result;
             * }
             *
             * // Create Google Calendar API service.
             * var service = new CalendarService(new BaseClientService.Initializer()
             * {
             *  HttpClientInitializer = credential,
             *  ApplicationName = ApplicationName,
             * });
             *
             * String calendarId = "primary";
             * String eventId = name;
             *
             * service.Events.Delete(calendarId, eventId);
             */
            File.Delete(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\" + name + ".mevent");
            Message.Text = "Visit deleted from Google Calendar!";
            Message.Show();
            this.Close();
        }
Ejemplo n.º 3
0
        private void SendButton_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(textBoxMyMail.Text) || string.IsNullOrWhiteSpace(textBoxMyPassword.Text) || string.IsNullOrWhiteSpace(textBoxRecipent.Text) || string.IsNullOrWhiteSpace(textBoxSubject.Text) || string.IsNullOrWhiteSpace(textBoxBody.Text))
            {
                MailWindowMessageBox Message = new MailWindowMessageBox();
                Message.Text = "Please set all information in Window!";
                Message.Show();
            }
            else
            {
                if (checkBoxNow.CheckState == CheckState.Checked)
                {
                    try
                    {
                        /// SEND MAIL NOW
                        var message = new MailMessage(textBoxMyMail.Text, textBoxRecipent.Text);                    /// email, recipent
                        message.Subject = textBoxSubject.Text;                                                      /// email subject
                        message.Body    = textBoxBody.Text;                                                         /// email body

                        using (SmtpClient mailer = new SmtpClient("smtp.gmail.com", 587))                           /// loging to SMTP client
                        {
                            mailer.Credentials = new NetworkCredential(textBoxMyMail.Text, textBoxMyPassword.Text); /// email, password
                            mailer.EnableSsl   = true;
                            mailer.Send(message);
                        }
                        /// CREATE COPY OF SENDED MAIL
                        TextWriter Save = new StreamWriter(yearBox.Text + MonthBox.Text + DayBox.Text + HourBox.Text + MinBox.Text + ".smail");
                        Save.WriteLine("M");
                        Save.WriteLine(yearBox.Text);
                        Save.WriteLine(MonthBox.Text);
                        Save.WriteLine(DayBox.Text);
                        Save.WriteLine(HourBox.Text + ":" + MinBox.Text);
                        Save.WriteLine("yes");
                        Save.WriteLine(textBoxMyMail.Text);
                        Save.WriteLine(textBoxMyPassword.Text);
                        Save.WriteLine(textBoxRecipent.Text);
                        Save.WriteLine(textBoxSubject.Text);
                        Save.WriteLine(textBoxBody.Text);

                        MailWindowMessageBox Message = new MailWindowMessageBox();
                        Message.Text = "Message Send!";
                        Message.Show();

                        Save.Close();
                    }
                    catch (Exception ex)
                    {
                        MailWindowMessageBox Message = new MailWindowMessageBox();
                        Message.Text = "Mail not Send!";
                        Message.Show();
                    }
                }
                else
                {
                    if (string.IsNullOrWhiteSpace(yearBox.Text) || string.IsNullOrWhiteSpace(MonthBox.Text) || string.IsNullOrWhiteSpace(DayBox.Text) || string.IsNullOrWhiteSpace(HourBox.Text) || string.IsNullOrWhiteSpace(MinBox.Text))
                    {
                        MailWindowMessageBox Message = new MailWindowMessageBox();
                        Message.Text = "Please select date for sending mail!";
                        Message.Show();
                    }
                    else
                    {
                        /// CREATE TXT FILE WITH MAIL INFORMATION AND SEND DATE
                        TextWriter Save = new StreamWriter(yearBox.Text + MonthBox.Text + DayBox.Text + HourBox.Text + MinBox.Text + ".smail");

                        Save.WriteLine("M");
                        Save.WriteLine(yearBox.Text);
                        Save.WriteLine(MonthBox.Text);
                        Save.WriteLine(DayBox.Text);
                        Save.WriteLine(HourBox.Text + ":" + MinBox.Text);
                        Save.WriteLine("no"); /// IS MAIL SENDED?
                        Save.WriteLine(textBoxMyMail.Text);
                        Save.WriteLine(textBoxMyPassword.Text);
                        Save.WriteLine(textBoxRecipent.Text);
                        Save.WriteLine(textBoxSubject.Text);
                        for (int i = 0; i < textBoxBody.Lines.Length; i++)
                        {
                            Save.WriteLine(textBoxBody.Lines[i]);
                        }

                        Save.Close();
                        MailWindowMessageBox Message = new MailWindowMessageBox();
                        Message.Text = "Mail added to queue!";
                        Message.Show();
                    }
                }
            }
        }