SearchEmailTemplates
Description
The SeachEmailTemplates method retrieves EmailTemplate objects from the EBizCharge platform.
Syntax
EmailTemplate[] SearchEmailTemplates(SecurityToken securityToken, SearchFilter[] filters, int start, int limit, string sort)
Arguments
Type | Name | Description | |
|---|---|---|---|
| SecurityToken | securityToken | R | A unique token that is used to identify a merchant and authenticate the API request. |
| SearchFilter | filters | O | Filter email templates by one or more field names, comparison operators, and field values. See supported search parameters below. |
int | start | R | Index of the first object to return in the array. Note: Must be ≥ 0. |
int | limit | R | Maximum number of objects to return. Note: Must be > 0. |
string | sort | O | Sorts by field name. Note: Not currently used. |
Supported Search Parameters
| Parameter | Description | Example Use |
|---|---|---|
| TemplateName | Filters by the name of the template. | |
| TemplateInternalId | Filters by the internal template ID. | |
| TemplateSubject | Filters by the subject of the template. | |
| TemplateDescription | Filters by the template description. | |
| FromEmail | Filters by the from email. | |
| FromName | Filters by the from name. | |
| TemplateTypeId | Filters by the template type ID. | |
Return Value
| Type | Description |
|---|---|
| EmailTemplate[] | Array of email templates matching the entered parameters. 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:SearchEmailTemplates>
<ebiz:securityToken>
<ebiz:SecurityId>***********-4bf0-91cd***********</ebiz:SecurityId>
<ebiz:UserId/>
<ebiz:Password/>
</ebiz:securityToken>
<ebiz:filters>
<ebiz:SearchFilter>
<ebiz:FieldName>TemplateName</ebiz:FieldName>
<ebiz:ComparisonOperator>ne</ebiz:ComparisonOperator>
<ebiz:FieldValue>Email Pay for Sales Order</ebiz:FieldValue>
</ebiz:SearchFilter>
</ebiz:filters>
<ebiz:start>0</ebiz:start>
<ebiz:limit>2</ebiz:limit>
<ebiz:sort/>
</ebiz:SearchEmailTemplates>
</soapenv:Body>
</soapenv:Envelope>public static void SearchEmailTemplates()
{
IeBizService apiClient = new IeBizServiceClient();
SecurityToken securityToken = new SecurityToken
{
SecurityId = TestSecurityId,
UserId = "",
Password = ""
};
SearchFilter[] filters =
{
new SearchFilter
{
FieldName = "TemplateName",
ComparisonOperator = "eq",
FieldValue = "WebFormEmail"
}
};
EmailTemplate[] templates = apiClient.SearchEmailTemplates(
securityToken,
filters,
0,
100,
"TemplateName"
);
if (templates == null || templates.Length == 0)
{
Console.WriteLine("No email templates found.");
return;
}
foreach (EmailTemplate template in templates)
{
Console.WriteLine($"Template Name: {template.TemplateName}");
Console.WriteLine($"Template Internal ID: {template.TemplateInternalId}");
Console.WriteLine($"Subject: {template.TemplateSubject}");
Console.WriteLine($"Description: {template.TemplateDescription}");
Console.WriteLine($"From Email: {template.FromEmail}");
Console.WriteLine($"From Name: {template.FromName}");
Console.WriteLine($"Reply-To Email: {template.ReplyToEmail}");
Console.WriteLine($"Reply-To Display: {template.ReplyToDisplayName}");
Console.WriteLine($"Source: {template.TemplateSource}");
Console.WriteLine($"Type ID: {template.TemplateTypeId}");
Console.WriteLine(new string('-', 50));
}
}function searchEmailTemplates($client, $securityToken): void
{
$client = new SoapClient('End Point URL');
$securityToken = array(
'SecurityId' => '********-1b21-421b-86ce-************',
'UserId' => 'merchant1',
'Password' => 'merchant1'
);
$filters = [
[
'FieldName' => 'TemplateName',
'ComparisonOperator' => 'eq',
'FieldValue' => 'WebFormEmail',
],
];
$response = $client->SearchEmailTemplates([
'securityToken' => $securityToken,
'filters' => $filters,
'start' => 0,
'limit' => 100,
'sort' => 'TemplateName',
]);
// Normalize to array regardless of single or multiple results
$templates = $response->SearchEmailTemplatesResult->EmailTemplate ?? null;
if (empty($templates)) {
echo "No email templates found." . PHP_EOL;
return;
}
if (!is_array($templates)) {
$templates = [$templates];
}
foreach ($templates as $template) {
echo "Template Name: " . ($template->TemplateName ?? '') . PHP_EOL;
echo "Template Internal ID: " . ($template->TemplateInternalId ?? '') . PHP_EOL;
echo "Subject: " . ($template->TemplateSubject ?? '') . PHP_EOL;
echo "Description: " . ($template->TemplateDescription ?? '') . PHP_EOL;
echo "From Email: " . ($template->FromEmail ?? '') . PHP_EOL;
echo "From Name: " . ($template->FromName ?? '') . PHP_EOL;
echo "Reply-To Email: " . ($template->ReplyToEmail ?? '') . PHP_EOL;
echo "Reply-To Display: " . ($template->ReplyToDisplayName ?? '') . PHP_EOL;
echo "Source: " . ($template->TemplateSource ?? '') . PHP_EOL;
echo "Type ID: " . ($template->TemplateTypeId ?? '') . PHP_EOL;
echo str_repeat('-', 50) . PHP_EOL;
}
}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">
<SearchEmailTemplatesResponse xmlns="http://eBizCharge.ServiceModel.SOAP">
<SearchEmailTemplatesResult>
<EmailTemplate>
<TemplateName>NewReceipt-Customer</TemplateName>
<TemplateInternalId>***********-4f46-aba1-***********</TemplateInternalId>
<TemplateSubject>NewReceipt-Customer</TemplateSubject>
<TemplateDescription>NewReceipt-Customer</TemplateDescription>
<FromEmail>[email protected]</FromEmail>
<FromName>EBizCharge</FromName>
<ReplyToEmail>[email protected]</ReplyToEmail>
<ReplyToDisplayName>Support</ReplyToDisplayName>
<TemplateSource>2</TemplateSource>
<TemplateTypeId>TransactionReceiptCustomer</TemplateTypeId>
</EmailTemplate>
<EmailTemplate>
<TemplateName>Receipt Tacos edited</TemplateName>
<TemplateInternalId>***********-4851-957a-***********</TemplateInternalId>
<TemplateSubject>Taco Receipt Tasty Tacos</TemplateSubject>
<TemplateDescription>Merchant receipt template edited</TemplateDescription>
<FromEmail>[email protected]</FromEmail>
<FromName>EBizCharge</FromName>
<ReplyToEmail>[email protected]</ReplyToEmail>
<ReplyToDisplayName>Support</ReplyToDisplayName>
<TemplateSource>2</TemplateSource>
<TemplateTypeId>TransactionReceiptMerchant</TemplateTypeId>
</EmailTemplate>
</SearchEmailTemplatesResult>
</SearchEmailTemplatesResponse>
</s:Body>
</s:Envelope><s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<s:Fault>
<faultcode xmlns:a="http://schemas.microsoft.com/net/2005/12/windowscommunicationfoundation/dispatcher">a:InternalServiceFault</faultcode>
<faultstring xml:lang="en-US">The server was unable to process the request due to an internal error. For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the <serviceDebug> configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework SDK documentation and inspect the server trace logs.</faultstring>
</s:Fault>
</s:Body>
</s:Envelope>Updated 7 days ago
