1973 Ltd

Creating Emails in Eloqua using the API – Article 1 from a series of 3

Creating emails in Eloqua

Using PHP and the RESTful API to create an email from HTML.

This is a bit of a follow on to Dave’s great post on sending emails via the Eloqua API, this time we thought we’d show you how to create the email in the first place.  This is a really scalable solution and provides many benefits including:

  • Less copy & pasting via the Eloqua interface i.e. the HTML source files and the subject lines
  • Less configuring of email groups, folders, footers, headers etc
  • Less copy & pasting via the Eloqua interface i.e. the HTML source and the subject line
  • Less room for human error
  • Expedited workflows

We host all assets via Amazon AWS for speed of delivery and again improved workflows and updating of content. So lets get going, firstly like always we establish connection to our Eloqua instance, using our normal login credentials.

We need to define some static variables to hold the Email Group ID and Folder ID (the folder in Eloqua the email is going to reside in).  These are integer values that we use another 2 API calls to find these values in Eloqua (you can dig around and inspect the Eloqua interface to discover these values but its clunky to say the least).

We define and initialise two objects to hold our data.

Initialise these objects:

So now the email can be assembled in HTML using PHP. We upload a set of HTML files and subject lines text files (UTF-8) which we spin through via a loop in PHP using the file names and file extensions to determine and create the email in Eloqua (Eloqua allows you to create multiple emails with the same name, be warned!). All images would be remotely linked but URL’s can go in normally, eg https://community.oracle.com/community/topliners/ but with the additional querystring ‘?elqTrack=true’ appended to them and they will be tracked using the setting ‘isTracked’ as below. So an url would be like :


We then put it together in the objects.

We now need to hit the API with a create call

Your email has now been created!  Some caveats to be wary of, Eloqua likes well formatted HTML and the API will fail if you provide badly formatted HTML (which you don’t want to do anyway).  Make sure you also stick to UTF-8 encoding to maintain double byte character sets.

We can now do some basic error checking to detect any problems:

And finally little bit of tidying up.

And that’s it, next in the series we’ll show you how to update an existing email in Eloqua via the API and then how to delete an email again via the API.

Comments  -  0 Comments

There are no comments yet.

Leave a reply

Follow our blog!

Recent Posts


Our latest tweets