API: Scheduled Import Email Addresses from a CSV

How to Automate User Email Import with EveryonePrint API from CSV

Issue:

EveryonePrint includes a REST-based API, which can be used for automated tasks, such as importing users' email addresses from a scheduled task.

Resolution:

Refer to EveryonePrint Install Guide for general configuration and usage of the REST API (chapter "17. EveryonePrint API").

The following guide outlines an example of a text file containing usernames and email addresses for users and a Windows BAT file that can be scheduled in the Windows scheduler.

  • Create a txt file called emails.txt containing user email addresses, such as:

    john,john@gmail.com<br />jane,jane@gmail.com
  • Create a bat file called email-import.bat containing the following script:

    @echo off<br />setlocal<br />for /f "Tokens=*" %%a in (<strong>emails.txt</strong>) do set line=%%a&amp;call :parse<br />endlocal<br />goto :EOF<br />:parse<br />for /f "Tokens=1-2 Delims=, " %%a in ("%line%") do set username=%%a&amp;set emailaddress=%%b<br />echo Adding email address User: [%username%] Email: [%emailaddress%]<br />"<strong>C:\Program Files (x86)\EveryonePrint\lib\windows\curl\curl.exe</strong>" -X PUT -i -H "<strong>X-EOP-AuthToken: xyz</strong>" "<strong>http://127.0.0.1:7290</strong>/api/rest.cfm/useremails/?username=%username%&amp;EmailAddress=%emailaddress%"
  • Modify/amend the values in bold above for:
    • filename
    • path to Curl
    • API authorization token
    • URL to EveryonePrint server
  • When executing this bat file, the email addresses in the txt file will be imported.

    Command Line Output Showing Successful Email Address Addition for EveryonePrint Users