Code to Create a List
Lists can be created from a text file, an SQL query, an analysis report, or a Predictor resource segment. This section describes how to create a list named 'Users1' from a file named Users.csv. Once the list is created, the number of unique users imported into the list is retrieved.
Create the Users.csv text file. A representative section of the file follows that contains the e-mail addresses and IDs for a group of users.
joeuser@roguecellars.com,Newuser_R121 barneyuser@fabrikam.com,Olduser_F3 bettyuser@arborshoes.com,Newuser_A872 jackuser@vigorairlines.com,Olduser_V83 jilluser@microsoft.com,Olduser_M2901
Use the initialized ListManager object, oListManager, created in Code to Initialize the ListManager Object, to create a Mailable User list (userFlags = 20) from the text file.
Dim vListID1, vOperationID vListID1 = oListManager.CreateFromFile("Users1", "Just users", _ 20, 0, "D:\Users.csv", 0, True, vOperationID)
Set the maximum time allowed for the list to be created to 10 minutes (600 seconds). If the list is not created in this time, the method will return an error.
oListManager.WaitOnOperation vOperationID, 600
When the creation operation finishes, retrieve the number of unique e-mail addresses imported.
Dim rsOperationInfo, vOperationStatus, vUniqueUsers Set rsOperationInfo = oListManager.GetOperationInfo(vOperationID) vOperationStatus = rsOperationInfo("op_status") If vOperationStatus = 0 Then vUniqueUsers = oListManager.GetListProperty(vListID1, _ "list_unique_emails") Wscript.Echo "Number of unique users is " & vUniqueUsers & vbCrLf ElseIf vOperationStatus = 1 Then Wscript.Echo "List still being created" & vbCrLf ElseIf vOperationStatus = -1 Then Wscript.Echo "List creation failed" & vbCrLf Else Wscript.Echo "Bad status code" & vbCrLf End If
Release the objects.
Set oListManager = Nothing Set rsOperationInfo = Nothing