create subscribers if they don't exist

Jul 17, 2012 at 3:05 PM

I would like to download all our email subscribers from our CRM (including first name, surname and email) and send them to mail chimp.  

However, if they already exist in mail chimp I don't want to re-create them or change their opt-in/out preference, so if they have opted out I don't want to reactivate their subscription.

I have used the code below to test creating subscribers, but this will also reactivate the opt-in:


        Dim cmd As New listSubscribe()
        Dim newlistSubscribeParms As New listSubscribeParms()

        newlistSubscribeParms.apikey = apikey = "12345"
        newlistSubscribeParms.email_address = ""
        newlistSubscribeParms.double_optin = False
        newlistSubscribeParms.email_type = EnumValues.emailType.html
        newlistSubscribeParms.replace_interests = True
        newlistSubscribeParms.send_welcome = False
        newlistSubscribeParms.update_existing = True

        Dim newlistSubscribeInput As New listSubscribeInput(newlistSubscribeParms)
        Dim subscribeSuccess = cmd.Execute(newlistSubscribeInput)

        If subscribeSuccess.result Then
            MsgBox("Added ok", MsgBoxStyle.Information)
            MsgBox("Failed", MsgBoxStyle.Exclamation)
        End If

Jul 20, 2013 at 7:06 AM
Edited Jul 20, 2013 at 7:07 AM
Used this code in for checking email exits in mail chimp List or not

public string findlist(string email)
    string apikey = "c5e29fgdfgdfgdfgfdgdfg";
   string listId = "d9c5jghjdfgdfg";
    listMembersInput listIn = new listMembersInput(apikey, listId, EnumValues.listMembers_status.subscribed, 0, 100);
    listMembers listMem = new listMembers(listIn);
    listMembersOutput listOut = listMem.Execute();
    string[] email = new string[listOut.result.Count];
    //string[] email1 = new string[100];
    for (int i = 0; i < listOut.result.Count; i++)
        email[i] = listOut.result[i].ToString();
        //email1[i] = email[i].Split(',').ToString();
        if (email[i].Split(',')[0].ToString().Split(':')[1].ToString().Trim() == email)
           return "Your have already belongs";
    return string.Empty;