Guest User

Untitled

a guest
Jul 7th, 2017
522
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Campaign aCampaign = new Campaign();
  2.  
  3. aCampaign.Type = CampaignType.Regular;
  4. aCampaign.Recipients = new Recipient
  5. {
  6. ListId = "ab641dbfd3"
  7. };
  8. aCampaign.Settings = new Setting
  9. {
  10. SubjectLine = $"Campaign created by program at {DateTime.UtcNow.ToString("s")}",
  11. Title = $"Dynamic campaign {Guid.NewGuid()}",
  12. FromName = "Alexandre Veillet",
  13. ReplyTo = "webmaster@mindfintech.fr"
  14. };
  15. aCampaign.Tracking = new Tracking
  16. {
  17. Opens = false,
  18. HtmlClicks = false,
  19. TextClicks = false
  20. };
  21.  
  22. aCampaign.ReportSummary = new ReportSummary();
  23. aCampaign.DeliveryStatus = new DeliveryStatus();
  24.  
  25.  
  26. var content = new ContentRequest
  27. {
  28. PlainText = "Hello world! I am testing Doug Vanderweide's MailChimp.NET.V3 demo, at https://www.dougv.com",
  29. Html = "<!doctype html><html lang=\"en\"><head><meta charset=\"utf-8\"><title>title</title></head><body><p>Hello world! I am testing Doug Vanderweide's MailChimp.NET.V3 demo, at <a href=\"https://www.dougv.com\">https://www.dougv.com</a></body></html>"
  30. };
  31.  
  32. try
  33. {
  34. await mc_mngr.Campaigns.AddOrUpdateAsync(aCampaign);
  35.  
  36. await mc_mngr.Content.AddOrUpdateAsync(aCampaign.Id, content);
  37.  
  38. await mc_mngr.Campaigns.SendAsync(aCampaign.Id);
  39. }
  40. catch (MailChimpException mce)
  41. {
  42. //return new HttpStatusCodeResult(HttpStatusCode.BadGateway, mce.Message);
  43. Console.WriteLine(mce.Message);
  44. }
  45. catch (Exception ex)
  46. {
  47. //return new HttpStatusCodeResult(HttpStatusCode.ServiceUnavailable, ex.Message);
  48. Console.WriteLine(ex.Message);
  49. }
RAW Paste Data