예제 #1
0
        public static Tuple <bool, string> SendCloudEmail(string dst, string subject, string body, List <Attachment> attachmentList, VPlatform platform, VLogger logger)
        {
            string error = "";

            logger.Log("Utils.SendCloudEmail called with " + dst + " " + subject + " " + body);

            string smtpServer     = platform.GetPrivateConfSetting("SmtpServer");
            string smtpUser       = platform.GetPrivateConfSetting("SmtpUser");
            string smtpPassword   = platform.GetPrivateConfSetting("SmtpPassword");
            Uri    serviceHostUri = new Uri("https://" + platform.GetConfSetting("EmailServiceHost") + ":" + Shared.Constants.EmailServiceSecurePort + "/" +
                                            Shared.Constants.EmailServiceWcfEndPointUrlSuffix);

            string bodyLocal;

            CloudEmailer emailer = new CloudEmailer(serviceHostUri, 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));
        }
예제 #2
0
        public static Tuple<bool, string> SendCloudEmail(string dst, string subject, string body, List<Attachment> attachmentList, VPlatform platform, VLogger logger)
        {
            string error = "";
            logger.Log("Utils.SendCloudEmail called with " + dst + " " + subject + " " + body);

            string smtpServer = platform.GetPrivateConfSetting("SmtpServer");
            string smtpUser = platform.GetPrivateConfSetting("SmtpUser");
            string smtpPassword = platform.GetPrivateConfSetting("SmtpPassword");
            Uri serviceHostUri = new Uri("https://" + platform.GetConfSetting("EmailServiceHost") + ":" + Shared.Constants.EmailServiceSecurePort + "/" +
                                   Shared.Constants.EmailServiceWcfEndPointUrlSuffix);

            string bodyLocal;

            CloudEmailer emailer = new CloudEmailer(serviceHostUri, 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);
        }