Exemplo n.º 1
0
        public MailContentData CreateTemperatureEmailAlertMessage(EmailTemperatureHitParameter infoParameter, ILogger logger)
        {
            var mailData = new MailContentData();

            mailData.MailInfo = new MailInfo();

            logger.LogInformation("Getting sender/recipient email address.");
            var recipients = GetEmailAddress(infoParameter.DeviceId);

            if (recipients == null)
            {
                throw new ArgumentNullException("Recipients is null, please ensure recipient are setup properly.");
            }

            mailData.MailInfo.Recipients  = recipients;
            mailData.MailInfo.Subject     = _temperatureFilterConfiguration.Subject;
            mailData.MailInfo.ContentBody = ApplyTextReplacement(infoParameter);
            mailData.MailInfo.Sender      = _temperatureFilterConfiguration.Sender;
            mailData.MailInfo.SenderName  = _temperatureFilterConfiguration.SenderName;
            return(mailData);
        }
Exemplo n.º 2
0
 private string ApplyTextReplacement(EmailTemperatureHitParameter mailInfo)
 {
     mailInfo.EmailMessage = mailInfo.EmailMessage.ReplaceContent(ThermoUnitPlaceHolderReplacement, mailInfo.DeviceId).ReplaceContent(IncidentDatePlaceHolderReplacement, mailInfo.Timestamp.ToString()).ReplaceContent(TemperaturePlaceHolderReplacement, mailInfo.TemperatureRegistered.ToString()).ReplaceContent(ImagePlaceHolderReplacement, mailInfo.Image);
     return(mailInfo.EmailMessage);
 }