Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 46379

Integration with MailChimp

$
0
0

Hi all

I have below code which I write for some testing in c#.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net;
using System.IO;
using Newtonsoft.Json;

namespace TestForMailChimp
{
class Program
{
static void Main(string[] args)
{
var sampleList = JsonConvert.SerializeObject(
new
{
name = "Sample List",
contact = new
{
company = "MailChimp",
address1 = "675 Ponce De Leon Ave NE",
address2 = "Suite 5000",
city = "zip",
state = "GA",
zip = "30308",
country = "US",
phone = ""
},
permission_reminder = "You'\''re receiving this email because you signed up for updates about Freddie'\''s newest hats.",
campaign_defaults = new
{
from_name = "Freddie",
from_email = "freddie@freddiehats.com",
subject = "MailChimp Demo",
language = "en",
},
email_type_option = true
});
var uri = string.Format("https://{0}.api.mailchimp.com/3.0/lists", "");

try
{
using (var webClient = new WebClient())
{
webClient.Headers.Add("Accept", "application/json");
webClient.Headers.Add("Authorization", "apikey " + "ab15c4df98b952ca886a92e5a");

Console.WriteLine(webClient.UploadString(uri, "POST", sampleList));
}
}
catch (WebException we)
{
using (var sr = new StreamReader(we.Response.GetResponseStream()))
{
Console.WriteLine(sr.ReadToEnd());
}
}
}
}
}

I want to use this code on a custom button in crm. How can I use it.?

Thank you


Viewing all articles
Browse latest Browse all 46379

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>