0

I have gotten so far that I can create a new campaign in my campaign list in mailchimp using a java class, however, I am not getting there to send it, see code, does anyone have suggestions?

it executes the creation of the campaign (and i see it in mailchimp), and I receive back the campaignInfo object, but from the point to send this campaign, I cant figure it out

    package mailingapp2;

    import com.ecwid.maleorang.MailchimpClient;
    import com.ecwid.maleorang.method.v3_0.campaigns.CampaignActionMethod;
    import com.ecwid.maleorang.method.v3_0.campaigns.CampaignInfo;
    import com.ecwid.maleorang.method.v3_0.campaigns.CampaignInfo.SettingsInfo;
    import static com.ecwid.maleorang.method.v3_0.campaigns.CampaignInfo.Type.PLAINTEXT;
    import com.ecwid.maleorang.method.v3_0.campaigns.EditCampaignMethod;

    public class SendMailchimpCampaign {

        public void SendCampaign() throws Exception {
        String apiKey = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
            String listId = "d069f8c902";
            String Email ="test@test.be";
            String firstName = "test";
            String lastName = "test";
        MailchimpClient client = new MailchimpClient(apiKey);

        try{
        EditCampaignMethod.Create method = new EditCampaignMethod.Create();
        method.type = PLAINTEXT;
        method.settings = new SettingsInfo();
        method.settings.mapping.put("title", "test2");
        method.settings.mapping.put("subject_line", "test");
        method.settings.mapping.put("from_name", "test");
        method.settings.mapping.put("reply_to", "info@test.be");

        CampaignInfo campaign = client.execute(method); //until here it works, //it executes, and I receive back the campaignInfo object, but from here I can't //figure it out how to move on to send this campaign.

         CampaignActionMethod.Send send = new CampaignActionMethod.Send(listId);

         System.out.println("info" + campaign);

 }catch (Exception e) {
        System.err.println("Caught IOException: " + e.getMessage());
          }

        }
    }
ekad
  • 14,436
  • 26
  • 44
  • 46

1 Answers1

0

It seems you should add

client.execute(send);

right after

CampaignActionMethod.Send send = new CampaignActionMethod.Send(listId);

user1195526
  • 542
  • 7
  • 8
  • Hello i have added like so, he tries to execute, (listId should be CampaignId) i have been able to add the list_id `RecipientsInfo r = new RecipientsInfo(); r.list_id="xxxxxxxxxx"; r.list_name="testlijst";method.recipients = r;` but now i am struggling with the contents, how to put them in. – user7715658 Apr 19 '17 at 11:26
  • for who is intrested, this is how i put contents and sent it `SetCampaignContentMethod sccm = new SetCampaignContentMethod(campaign.id); sccm.plain_text = "Dit is een testbericht"; client.execute(sccm); CampaignActionMethod.Send send = new CampaignActionMethod.Send(campaign.id); client.execute(send);` – user7715658 May 04 '17 at 09:17