GetEmailTemplates

Description

The GetEmailTemplates method retrieves a specific EmailTemplate object using templateInternalId, or templateInternalId and templateName. If neither ID is included, all email templates are returned.

Syntax

EmailTemplate[] GetEmailTemplates(SecurityToken securityToken, string templateInternalId, string templateName)

Arguments

Type

Name

Req.

Description

SecurityToken

securityToken

R

A unique token that is used to identify a merchant and authenticate the API request.

string

templateInternalId

D

Internal ID of the requested EmailTemplate object.

Note: Required if templateName is sent.

string

templateName

O

Template name of the requested EmailTemplate object.

Return Value

TypeDescription
EmailTemplate[]On success, return an array of EmailTemplate objects. Otherwise, returns a fault.

Example Request

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ebiz="http://eBizCharge.ServiceModel.SOAP">
   <soapenv:Header/>
   <soapenv:Body>
      <ebiz:GetEmailTemplates>
         <ebiz:securityToken>
            <ebiz:SecurityId>***************-b899-9301b636c223</ebiz:SecurityId>
            <ebiz:UserId/>
            <ebiz:Password/>
         </ebiz:securityToken>
         <ebiz:templateInternalId>*************a906-05319d5398e5</ebiz:templateInternalId>
         <ebiz:templateName>WebFormEmail</ebiz:templateName>
      </ebiz:GetEmailTemplates>
   </soapenv:Body>
</soapenv:Envelope>
private static void GetEmailTemplates()
{
  IeBizService apiClient = new IeBizServiceClient();
  SecurityToken securityToken = new SecurityToken
  {
    SecurityId = "*******-c870-41b8-aa5c-********", // Replace with your actual token
    UserId = "",
    Password = ""
    };
  string templateInternalId = "";
  string templateName = "CBS Template 1";
  EmailTemplate[] templates = apiClient.GetEmailTemplates(securityToken, templateInternalId, templateName);

  //Display results
  foreach (EmailTemplate template in templates) { 
    Console.WriteLine($"TemplateName:       {template.TemplateName}");
    Console.WriteLine($"TemplateInternalId: {template.TemplateInternalId}");
    Console.WriteLine($"TemplateSubject:    {template.TemplateSubject}");
    Console.WriteLine($"TemplateDescription:{template.TemplateDescription}");
    Console.WriteLine($"TemplateHTML:       {template.TemplateHTML}");
    Console.WriteLine($"TemplateText:       {template.TemplateText}");
  }
}
// Initialize the SOAP client (replace with your actual endpoint URL)
$client = new SoapClient("https://ebizsoapapidev1.ebizcharge.net/eBizService.svc?singleWsdl");

// Define the merchant security token
$securityToken = array(
  'SecurityId' => '*******-c870-41b8-aa5c-********',
  'UserId'     => '',
  'Password'   => ''
);

// Prepare parameters for the GetEmailTemplates call
$params = array(
  'securityToken' => $securityToken,
  'templateInternalId' => '',
  'templateName' => ''
);

try {
  // Make the SOAP request
  $response = $client->GetEmailTemplates($params);

  // Extract result object from response
  $result = $response->GetEmailTemplatesResult;

  // Display the response
  echo "<pre>";
  print_r($result);
  echo "</pre>";

} catch (SoapFault $e) {
  // Handle any SOAP errors
  echo "SOAP Error: " . $e->getMessage();
}

Example Response

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
   <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <GetEmailTemplatesResponse xmlns="http://eBizCharge.ServiceModel.SOAP">
         <GetEmailTemplatesResult>
            <EmailTemplate>
               <TemplateName>WebFormEmail</TemplateName>
               <TemplateInternalId>186f2085*************05319d5398e5</TemplateInternalId>
               <TemplateSubject>An invoice is ready for you.</TemplateSubject>
               <TemplateDescription>Payment</TemplateDescription>
     <TemplateHTML>PCFET0NUWVBFIGh0bWw+DQo8aHRtbCBsYW5nPSJlbiI+DQogICAgPGhlYWQ+DQogICAgICAgIDxtZXRhIGh0dHAtZXF1aXY9IkNvbnRlbnQtVHlwZSIgY29udGVudD0idGV4dC9odG1sOyBjaGFyc2V0PXV0Zi04IiAvPg0KICAgICAgICA8bWV0YSBuYW1lPSJ2aWV3cG9ydCIgY29udGVudD0id2lkdGg9ZGV2aWNlLXdpZHRoLCBpbml0aWFsLXNjYWxlPTEuMCIgLz4NCiAgICAgICAgPG1ldGEgaHR0cC1lcXVpdj0iWC1VQS1bnQ9IldlYmZsb3ciIGl0ZW1wcm9wPSJuYW1lIiAvPg0KICAgICAgICA8L2Rpdj4NCiAgICAgICAgPGRpdiBpdGVtdHlwZT0iaHR0cDovL3NjaGVtYS5vcmcvT2ZmZXIiIGl0ZW1wcm9wPSJhYm91dCI+DQogICAgICAgIDwvZGl2Pg0KICAgICAgICA8L2Rpdj4NCiAgICA8L2JvZHk+DQo8L2h0bWw+</TemplateHTML>
               <TemplateText/>
               <FromEmail/>
               <FromName/>
               <ReplyToEmail/>
               <ReplyToDisplayName/>
               <TemplateSource>2</TemplateSource>
               <TemplateTypeId>WebFormEmail</TemplateTypeId>
            </EmailTemplate>
         </GetEmailTemplatesResult>
      </GetEmailTemplatesResponse>
   </s:Body>
</s:Envelope>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
   <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <GetEmailTemplatesResponse xmlns="http://eBizCharge.ServiceModel.SOAP">
         <GetEmailTemplatesResult/>
      </GetEmailTemplatesResponse>
   </s:Body>
</s:Envelope>