17Oct, 2025
Sitecore Send Email Lists, or Any Other API List in Your Content Editor Dropdown
In my last post I covered sending data to a Send email list, and my last comment was about making sure Authors don't have to jump through hoops to get its Guid. In this post I'll share making this selection a custom field in Content Editor.
The Use Case
Like I said this example is in relation to the last post, but can be used for anything, really. The following base template is made available for any custom form in our solution, so the Author now has the ability to set the target email list and provide some tagging. The Developer will use these two fields and submit them along with form date to the helper I showed before.

Expanded, you can see the lists directly from Send. If you haven't guessed it the values are the Guids of each list.

Creating the Control
A dropdown is just an HTML Select which needs to be added to the list of available field types. ;
First, here's the config:
<sitecore> <configuration> <controlSources> <source mode="on" namespace="Sitecore.Foundation.Integrations.Controls" assembly="Sitecore.Foundation.Integrations" prefix="sendmaillistdropdown"/> </controlSources> </sitecore> </configuration>
The sendmaillistdropdown will output a simple bit of HTML like so:
public class SendMailListDropdown : Sitecore.Web.UI.HtmlControls.Control { protected override void DoRender(System.Web.UI.HtmlTextWriter output) { var allMailingLists = Helpers.Send.CachedMailingLists(); var sb = new StringBuilder(); sb.AppendLine("<select" + ControlAttributes + ">"); if (allMailingLists.Context.MailingLists.Any()) { sb.AppendLine($"<option value=\"\"></option>"); foreach (var mailingList in allMailingLists.Context.MailingLists.OrderBy(x => x.Name)) { if (mailingList.Id.ToString() == Value) { sb.AppendLine($"<option value=\"{mailingList.Id}\" selected=\"selected\">{mailingList.Name}</option>"); } else { sb.AppendLine($"<option value=\"{mailingList.Id}\">{mailingList.Name}</option>"); } } } else { sb.AppendLine($"<option value=\"\">WARNING - No mail lists found please check integration settings.</option>"); } sb.AppendLine("</select>"); output.Write(sb.ToString()); } protected override bool LoadPostData(string value) { if (value == null) return false; if (this.GetViewStateString("Value") != value) Sitecore.Context.ClientPage.Modified = true; this.SetViewStateString("Value", value); return true; } }
You then add a new field type to /sitecore/system/Field types/List Types/:

And then to your template:

You can find similar code all over but what I want to point out is this line:
var allMailingLists = Helpers.Send.CachedMailingLists();
I didn't want a potentially long call to an API to happen every time an Author needed this field, so I used an in-memory cache.
Caching the API Calls
What does CachedMailingLists do? It simply stores the email lists into a static property which purges every 10 minutes, or longer if you prefer.
In the following example, CachedAllMailingLists is returned immediately if it's not null and not expired (as defined in SendMailListCacheExpires). If not, it uses the Send gateway to get all active email lists and stores them in the aforementioned property, resets the timer, and returns the list. Now there's no calls to the API for 10 minutes.
You may have notice in the above screenshot the help text of, "It may take a few minutes for a new email list to appear here as a selection.", and now you know why!
private static DateTime SendMailListCacheExpires = DateTime.MinValue; private static AllMailingLists CachedAllMailingLists = new AllMailingLists(); public static AllMailingLists CachedMailingLists() { try { if (SendMailListCacheExpires > DateTime.Now && CachedAllMailingLists?.Context?.MailingLists != null) return CachedAllMailingLists; var listCount = 0; using (var sendGateway = new Gateways.SendGateway()) { var allMailingLists = sendGateway.GetAllActiveMailingLists(); if (allMailingLists?.Context?.MailingLists != null) { listCount = allMailingLists.Context.MailingLists.Count; var cacheLifetime = Configuration.Settings.GetIntSetting("Sitecore.Foundation.Integrations.SendMailListCacheExpires", 600); if (cacheLifetime > 0) { var myLogger = LoggerFactory.GetLogger(SitecoreExtensions.Constants.Logging.Constants.CustomLogger); var logPrefix = $"[{typeof(Send).FullName}.{MethodBase.GetCurrentMethod().Name}] ->"; SendMailListCacheExpires = DateTime.Now.AddSeconds(cacheLifetime); CachedAllMailingLists = allMailingLists; myLogger.Info($"{logPrefix} Caching {listCount} email lists until {SendMailListCacheExpires:HH:mm:ss}"); } return allMailingLists; } } } catch (Exception ex) { var myLogger = LoggerFactory.GetLogger(SitecoreExtensions.Constants.Logging.Constants.CustomLogger); var logPrefix = $"[{typeof(Send).FullName}.{MethodBase.GetCurrentMethod().Name}] ->"; myLogger.Error($"{logPrefix} {ex.ToString()}"); } return new AllMailingLists(); }