Adding Emails to a List

Add multiple email/contact with associated fields to the specified list.


Function

  • addContacts()

Parameters

  • username: String
    • Account login name.
  • password: String
    • Account password.
  • listId: int
    • id of the list to which the email will be added to.
  • emailWithfieldValues: String[]
    • Email Address and Field values, split by comma.
    • Example: example@domain.com,field1,field2,field3
    • array of the field values as specified for the list. This will constitute one entry in the list.
  • allowDuplicates: boolean
    • insert an email even if it exists in the list specified.
  • actionCode: int
    • action code of how to handle duplicated email.
      • 0: failure.
      • 1: return existing record if email existed in the list specified.

Return

  • Contact[]:
    • The Array of Contact object that contain new contact Id.

Exception

  • Exception

Documentation

  • Add multiple email/contact with associated fields to the specified list.

Examples

public void addContactToListSample(int listId) throws java.lang.Exception {

        Puresend p = new Puresend();
        PuresendPortType port = p.getPuresendHttpsSoap12Endpoint();

        String username = "XXX";
        String password = "XXX";
        int listId = 1234;
        List<String> emailAndFieldValues = new ArrayList<>();
        emailAndFieldValues.add("email1@domain.com,FirstName,LastName,Address");
        emailAndFieldValues.add("email2@domain.com,FirstName,LastName,Address");

        Contact[] contacts = port.addContacts(username, password, listId, emailAndFieldValues, false, 0);
}
<?php
$url='https://<servername>/services/Puresend?wsdl';

$params = <<<EOT
         <ns1:addContacts>
             <ns1:username>XXX</ns1:username>
             <ns1:password>XXX</ns1:password>
             <ns1:listId>1234</ns1:listId>
             <ns1:emailWithfieldValues>email1@domain.com,FirstName,LastName,Address</ns1:emailWithfieldValues>
             <ns1:emailWithfieldValues>email2@domain.com</ns1:emailWithfieldValues>
             <ns1:allowDuplicates>true</ns1:allowDuplicates>
             <ns1:actionCode>0</ns1:actionCode>
         </ns1:addContacts>
EOT;

$sopaVar = new SoapVar($params, XSD_ANYXML);

$client = new SoapClient($url);


$res = $client->addContacts($sopaVar);


var_dump($res);


?>