async void StartSending() { if (!Validate()) { return; } var errors = new List <Exception>(); var from = TextBox_From.Text; var subject = TextBox_Subject.Text; var body = TextBox_Body.Text; var attachement = TextBox_Attachement.Text; Button_Send.IsEnabled = false; foreach (var recepient in _recepients) { try { var result = await GMailHelpers.SendEmailAsync(_gmailService, from, recepient, subject, body, attachement, true); } catch (Exception ex) { ex.HelpLink = recepient; errors.Add(ex); } } Button_Send.IsEnabled = true; if (errors.Count == 0) { MessageBox.Show("Operation Complete!"); } else { var sb = new StringBuilder("Following errors occurred: " + Environment.NewLine); errors.ForEach(e => { sb.Append($"{e.HelpLink}: {e.Message}{Environment.NewLine}"); }); ShowErrorMessage(sb.ToString()); } }
private void InitiateSession() { _gmailService = GMailHelpers.GetGMailService(CommonHelpers.Scopes); }