HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
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);
    }
}