Example #1
0
    private void SendEmail()
    {
        // The Send button is a toolbar button which doesn't take the focus. Move the focus so that the Binding updates the source before reading the HasErrors property.
        shellService.CommitUIChanges();

        var email = NewEmailViewModel.Email;

        if (email.HasErrors)
        {
            messageService.ShowError("One or more fields are not valid. Please correct them before sending this email.\n\n"
                                     + string.Join("\n", email.Errors.Select(x => x.ErrorMessage)));
            return;
        }
        NewEmailViewModel.Close();
        email.From = NewEmailViewModel.SelectedEmailAccount?.Email ?? "";
        email.Sent = DateTime.Now;
        Root.Sent.AddEmail(email);
    }