private void OnSend(object sender, EventArgs e)
        {
            var item = GetSelectedContact();

            if (item == null)
            {
                return;
            }

            var form = new EmailForm
            {
                Contact = item
            };

            if (form.ShowDialog(this) == DialogResult.Cancel)
            {
                return;
            }

            try
            {
                _messageDatabase.Send(form.Message);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            RefreshMessages();
        }
Beispiel #2
0
        /// <summary>
        /// Send an email to the selected contact
        /// </summary>
        private void sendEmailToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int index = contactsListBox.SelectedIndex;

            if (index == -1)
            {
                MessageBox.Show("Select first a contact from the list.", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            string        name    = contactsListBox.SelectedItem.ToString();
            PersonContact contact = (PersonContact)contactsList.FindContact(name);

            EmailForm form = new EmailForm(contact);

            if (form.ShowDialog() == System.Windows.Forms.DialogResult.Cancel)
            {
                return;
            }

            messagingService.Send(contact.EmailAddress, form.Subject, form.Message);
        }