Beispiel #1
0
        private void SentMail()
        {
            MailServer _composeMail = new MailServer();

            if (Mailtype.ComposeMail == MailTypeEnum || Mailtype.ReplyMail == MailTypeEnum || Mailtype.ForwardMail == MailTypeEnum)
            {
                Mail _mail = new Mail();
                _mail.EmailID     = txtEmail.Text;
                _mail.Subject     = txtSubject.Text;
                _mail.Message     = richTextBox1.Text;
                _mail.FromEmailId = LoginCredentials.LoggedEmailId;
                _mail.FileName    = txtAttachment.Text.Trim();
                string IsEmptyUSer = IsEmpty.CheckIfEmpty_Mail(_mail);
                int    User_id     = UserBusinessModel.GetUser(_mail.EmailID);

                if (IsEmptyUSer != null)
                {
                    MessageBox.Show(IsEmptyUSer, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    if (User_id != 0)
                    {
                        _mail.UserId = User_id;

                        if (_composeMail.SentMail(_mail))
                        {
                            if (SpeechModule.GetStatus() && MailTypeEnum == Mailtype.ComposeMail) //Only for compose mail help text speech work
                            {
                                synth.Speak("The mail sucessfully sent to the recipient");
                                synth.Speak("We are back to our main window");
                                List <Form> forms = new List <Form>();
                                foreach (Form f in Application.OpenForms)
                                {
                                    forms.Add(f);
                                }

                                foreach (Form f in forms)
                                {
                                    f.Hide();
                                }



                                Mailbox _mailbox = new Mailbox();
                                _mailbox.Show();
                            }
                            else
                            {
                                synth.Speak("The mail sucessfully sent to the recipient");
                                synth.Speak("We are back to our main window");
                                List <Form> forms = new List <Form>();
                                foreach (Form f in Application.OpenForms)
                                {
                                    forms.Add(f);
                                }

                                foreach (Form f in forms)
                                {
                                    f.Hide();
                                }



                                Mailbox _mailbox = new Mailbox();
                                _mailbox.Show();
                            }
                        }

                        else
                        {
                            MessageBox.Show("Unable to sent mail", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    else
                    {
                        MessageBox.Show("EmailID is not registered with our domain", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
            }
            else if (Mailtype.DraftMail == MailTypeEnum)
            {
                if (MailServer.ResentDraftMail(_msg_id))
                {
                    if (SpeechModule.GetStatus() && MailTypeEnum == Mailtype.ComposeMail) //Only for compose mail help text speech work
                    {
                        synth.Speak("The mail sucessfully sent to the recipient");
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("Mail sent sucessfully", "Sucess", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    }
                }
                else
                {
                    MessageBox.Show("Unable to sent mail", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }