using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Telerik.Sitefinity.Services; using Telerik.Sitefinity.Services.Notifications; namespace Telerik.Sitefinity.Documentation.CodeSnippets.DeepDive.NotificationService { public partial class NotificationServiceSnippets { public static void CreateMessageTemplateWithNewMessageJob() { var ns = SystemManager.GetNotificationService(); var context = new ServiceContext("myNotificationAccount", "MyCustomModule"); var cntxDictionary = new Dictionary<string, string>(); cntxDictionary.Add("MergeData.Time", DateTime.UtcNow.ToString()); var profileName = "DefaultSmtpProfile"; //Name of an existing profile Guid subscriptionListId = Guid.Empty; //Id of an existing subscription list var subjectTemplate = "Test notification"; var bodyTemplate = "Hi {|Subscriber.FirstName|} {|Subscriber.LastName|}, the time is: {| MergeData.Time|}"; IMessageTemplateRequest tmpl = new MessageTemplateRequestProxy() { Subject = subjectTemplate, BodyHtml = bodyTemplate }; var job = new MessageJobRequestProxy() { MessageTemplate = tmpl, SubscriptionsListId = subscriptionListId, SenderProfileName = profileName }; var messageJobId = ns.SendMessage(context, job, cntxDictionary); } } }