Example #1
0
        static void Main(string[] args)
        {
            var argsDict = ProcessArguments(args);

            Emailer emailer = new Emailer((string)argsDict["SmtpServer"], (string) argsDict["SmtpUser"], (string) argsDict["SmtpPassword"]);

            Notification notification = new Notification();
            //notification.toAddress = (String)argsDict["To"];
            notification.toAddress = "*****@*****.**";
            notification.subject = "homeos testing";
            notification.body = "This should just be fine, cheers";

            //this logger maps to stdout
            VLogger logger = new Logger();

            bool result = emailer.Send(notification, logger);

            logger.Log("result of email = " + result);
        }
Example #2
0
        /// <summary>
        /// Send email from Hub.
        /// </summary>
        /// <param name="dst">to:</param>
        /// <param name="subject">subject</param>
        /// <param name="body">body of the message</param>
        /// <returns>A tuple with true/false success and string exception message (if any)</returns>
        public static Tuple<bool, string> SendHubEmail(string dst, string subject, string body, List<Attachment> attachmentList, VPlatform platform, VLogger logger)
        {
            string error = "";
            logger.Log("Utils.SendHubEmail called with " + dst + " " + subject + " " + body);

            string smtpServer = platform.GetPrivateConfSetting("SmtpServer");
            string smtpUser = platform.GetPrivateConfSetting("SmtpUser");
            string smtpPassword = platform.GetPrivateConfSetting("SmtpPassword");
            string bodyLocal;

            Emailer emailer = new Emailer(smtpServer, smtpUser, smtpPassword, logger);

            if (string.IsNullOrWhiteSpace(body))
            {
                bodyLocal = platform.GetPrivateConfSetting("NotificationEmail");
            }
            else
            {
                bodyLocal = body;
            }

            Notification notification = BuildNotification(dst, subject, body, attachmentList);
            if (null == notification)
            {
                error = "Destination for the email not set";
                logger.Log(error);
                return new Tuple<bool, string>(false, error);
            }

            return emailer.Send(notification);
        }