File: D:/HostingSpaces/TDijk1/erp-apps.eu/wwwroot/App_Code/ERPApps/ERPNotifications.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using CMS.EmailEngine;
using CMS.CMSHelper;
using CMS.EventLog;
using CMS.DataEngine;
using CMS.TreeEngine;
using CMS.GlobalHelper;
using CMS.DocumentEngine;
using CMS.SiteProvider;
using CMS.Helpers;
using CMS.MacroEngine;
/// <summary>
/// Email notifications for admin/web editor.
/// </summary>
public class ERPNotifications
{
public static void SendNotificationToAdmin(string EmailTemplate, TreeNode node)
{
// create email message from template
EmailTemplateInfo eti = EmailTemplateProvider.GetEmailTemplate(EmailTemplate, SiteContext.CurrentSiteID);
if ( eti == null || DataHelper.IsEmpty(eti.TemplateCc))
{
// no template or no recipient
return;
}
GeneralConnection con = ConnectionHelper.GetConnection();
MacroResolver mcr = new MacroResolver();
if ( node != null )
{
mcr.SetNamedSourceData("nodealiaspath", node.NodeAliasPath);
}
// compose message
EmailMessage msg = new EmailMessage();
msg.EmailFormat = EmailFormatEnum.Both;
msg.From = eti.TemplateFrom;
msg.Recipients = eti.TemplateCc;
msg.Subject = eti.TemplateSubject;
msg.Recipients = eti.TemplateCc;
msg.BccRecipients = eti.TemplateBcc;
// send
EmailSender.SendEmailWithTemplateText(SiteContext.CurrentSiteName, msg, eti, mcr, true);
}
}