Esempio n. 1
0
        /// <summary>
        /// Helper Method to Send Site Owner Change Email notifcation.
        /// </summary>
        /// <param name="message"></param>
        public static void SendSiteOwnerChangeEmail(SuccessEmailMessage message)
        {
            try
            {               
                using (SmtpClient client = new SmtpClient())
                {
                    using (MailMessage emailMessage = new MailMessage())
                    {
                        emailMessage.Subject = message.Subject;
                        foreach (string to in message.To)
                        {
                            emailMessage.To.Add(to);
                        }

                        foreach (string cc in message.Cc)
                        {
                            emailMessage.CC.Add(cc);
                        }
                        AlternateView htmlView = AlternateView.CreateAlternateViewFromString(_emailConfig.GetSiteOwnerChangeEmailTemplateContent(message), null, "text/html");
                        emailMessage.AlternateViews.Add(htmlView);
                        client.Send(emailMessage);
                    }
                }
            }
            catch (Exception ex)
            {
                
            }
        }        
Esempio n. 2
0
        /// <summary>
        /// Helper Method to Send Site Owner Change Email notifcation.
        /// </summary>
        /// <param name="message"></param>
        public static void SendSiteOwnerChangeEmail(SuccessEmailMessage message)
        {
            try
            {
                using (SmtpClient client = new SmtpClient())
                {
                    using (MailMessage emailMessage = new MailMessage())
                    {
                        emailMessage.Subject = message.Subject;
                        foreach (string to in message.To)
                        {
                            emailMessage.To.Add(to);
                        }

                        foreach (string cc in message.Cc)
                        {
                            emailMessage.CC.Add(cc);
                        }
                        AlternateView htmlView = AlternateView.CreateAlternateViewFromString(_emailConfig.GetSiteOwnerChangeEmailTemplateContent(message), null, "text/html");
                        emailMessage.AlternateViews.Add(htmlView);
                        client.Send(emailMessage);
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
Esempio n. 3
0
        public string GetSiteOwnerChangeEmailTemplateContent(SuccessEmailMessage message)
        {
            string template = this.SuccessEmailTemplate;

            //template = template.Replace(TOKEN_TEMPLATEIMAGE, String.Format("cid:{0}", TOKEN_TEMPLATEIMAGE));
            template = template.Replace(TOKEN_SITEURL, message.SiteUrl);
            template = template.Replace(TOKEN_OLDSITEOWNER, message.OldSiteOwner);
            template = template.Replace(TOKEN_NEWSITEOWNER, message.NewSiteOwner);
            //template = template.Replace(TOKEN_STORAGELIMIT,
            //    String.Format(new FileSizeFormatProvider(), "{0:fs}", message.StorageLimit));

            return(template);
        }
Esempio n. 4
0
        public string GetSiteOwnerChangeEmailTemplateContent(SuccessEmailMessage message)
        {
            string template = this.SuccessEmailTemplate;

            //template = template.Replace(TOKEN_TEMPLATEIMAGE, String.Format("cid:{0}", TOKEN_TEMPLATEIMAGE));
            template = template.Replace(TOKEN_SITEURL, message.SiteUrl);
            template = template.Replace(TOKEN_OLDSITEOWNER, message.OldSiteOwner);
            template = template.Replace(TOKEN_NEWSITEOWNER, message.NewSiteOwner);
            //template = template.Replace(TOKEN_STORAGELIMIT,
            //    String.Format(new FileSizeFormatProvider(), "{0:fs}", message.StorageLimit));

            return template;
        }
Esempio n. 5
0
        protected void SendEmailNotification(string siteURL, string oldOwnerName, string newOwnerName, string oldSiteOwnerEmail, string newSiteOwnerEmail, List<PeoplePickerUser> usersSecondary)
        {
            try
            {
                StringBuilder _admins = new StringBuilder();
                SuccessEmailMessage _message = new SuccessEmailMessage();
                _message.SiteUrl = siteURL;
                _message.OldSiteOwner = oldOwnerName;
                _message.NewSiteOwner = newOwnerName;
                _message.Subject = "Your SharePoint Online site has a new Site Owner";

                _message.To.Add(oldSiteOwnerEmail);
                _message.To.Add(newSiteOwnerEmail);

                foreach (var admin in usersSecondary)
                {
                    _message.Cc.Add(admin.Email);
                    _admins.Append(admin.Name);
                    _admins.Append(" ");
                }
                //_message.SiteAdmin = _admins.ToString();
                EmailHelper.SendSiteOwnerChangeEmail(_message);
            }
            catch (Exception ex)
            {

            }
        }