In a previous post we discussed how to create and send Emails using Eloqua's SOAP API. You can use the same API to search for and retrieve emails, as well as email content and other properties such as Subject Line and Encoding Type. There are some great use-cases around the use of the API, for example you may wish to create Eloqua Emails using content from your own system and then leverage Eloqua's Email engine to deliver the message.

 

In this post, we'll demonstrate how to search for Emails and retrieve their content using the API. Like all "API How To" guides on this site, we'll assume that you are already familiar with the API Resources on this site - specifically connecting to the Eloqua API.

 

Sample C# code

 

    // Search for Emails with name containing 'Demand'  
    Email[] result = emailClient.SearchEmail("*Demand*");  
    foreach (var email in result)  
    {  
        Console.WriteLine("Id: " + email.Id);  
        Console.WriteLine("Name: " + email.Name);  
    }  

    // List all emails in your system  
    Email[] emails = emailClient.ListEmails();  

    // Iterate over each Email in the list  
    foreach (var email in emails)  
    {  
        // Display the name and subject  
        Console.WriteLine("Email Id: " + email.Id);  
        Console.WriteLine("Email name: " + email.Name);  
        Console.WriteLine("Subject: " + email.Subject);  

        // Retrieve the Email details  
        EmailDetails emailDetails = emailClient.GetEmailDetails(email.Id);  

        // Display some of the details  
        Console.WriteLine("Reply to Name: " + emailDetails.ReplyToName);  
        Console.WriteLine("Reply to Address: " + emailDetails.ReplyToAddress);  
        Console.WriteLine("From Name: " + emailDetails.FromName);  
        Console.WriteLine("From Address: " + emailDetails.FromAddress);  

        Console.WriteLine("HTML Content: " + emailDetails.HtmlContent);  
        Console.WriteLine("Send to Unsubscribes: " + emailDetails.SendToUnsubscribes);  
        Console.WriteLine("Header ID:" + emailDetails.HeaderId); // note : endpoints exist to pull information about the Header  
        Console.WriteLine("Footer ID:" + emailDetails.Footer);        // note : endpoints exist to pull information about the Footer  
    }