} // Execute private void UnsubscribeFromAllLists() { try { MCApi mailChimpApiClient = new MCApi(ConfigManager.CurrentValues.Instance.MailChimpApiKey, true); MCList <string> lists = mailChimpApiClient.ListsForEmail(this.email); if (lists != null && lists.Any()) { foreach (var list in lists) { var options = new List.UnsubscribeOptions { DeleteMember = true, SendGoodby = false, SendNotify = false }; var optOptions = new Opt <List.UnsubscribeOptions>(options); bool success = mailChimpApiClient.ListUnsubscribe(list, this.email, optOptions); if (success) { Log.Info("{0} was unsubscribed successfully from mail chimp", this.email); } } } } catch (MCException mcEx) { Log.Warn(mcEx.Error.ToString()); } catch (Exception ex) { Log.Warn(ex, "Failed unsubscribe from mail chimp email {0} for customer {1}", this.email, this.customerID); } }
} // GetCampaignAnalytics public void UnsubscribeFromAllLists(string email) { MCList <string> lists = m_oMcApi.ListsForEmail(email); if (lists != null && lists.Any()) { foreach (var list in lists) { m_oMcApi.ListUnsubscribe(list, email, new FSharpOption <List.UnsubscribeOptions>(new List.UnsubscribeOptions { DeleteMember = true, SendGoodby = false, SendNotify = false })); } } }