Beispiel #1
0
        internal void SendResetEmail(Login_DTO_Create dto, string token)
        {
            Resources.BBCode bbc = new Resources.BBCode();


            using (eMail email = new eMail())
            {
                string Body          = "";
                string Subject       = "";
                string InvitationUrl = "";

                Body          = Label.Get("email.body.account-reset", dto.LngIsoCode);
                Subject       = Label.Get("email.subject.account-reset", dto.LngIsoCode);
                InvitationUrl = "[url=" + Configuration_BSO.GetCustomConfig(ConfigType.global, "url.application") + Utility.GetCustomConfig("APP_COOKIELINK_INVITATION_1FA") + '/' + dto.CcnUsername + '/' + token + "]" + "[/url]";


                Body = Body + Environment.NewLine + InvitationUrl;
                Body = bbc.Transform(Body, true);

                email.Body    = Body;
                email.Subject = Subject;
                email.To.Add(dto.CcnEmail);

                email.Send();
            }
        }
Beispiel #2
0
        /// <summary>
        /// Send mails for a workflow
        /// </summary>
        /// <param name="email"></param>
        /// <param name="title"></param>
        /// <param name="subject"></param>
        /// <param name="body"></param>
        private void sendMail(eMail email, string title, string subject, string body)
        {
            BBCode bbc = new BBCode();

            body = bbc.Transform(body);
            var listToParse = new List <eMail_KeyValuePair>();

            listToParse.Add(new eMail_KeyValuePair()
            {
                key = "{title}", value = title
            });
            listToParse.Add(new eMail_KeyValuePair()
            {
                key = "{subject}", value = subject
            });
            listToParse.Add(new eMail_KeyValuePair()
            {
                key = "{website_name}", value = Configuration_BSO.GetCustomConfig("title")
            });
            listToParse.Add(new eMail_KeyValuePair()
            {
                key = "{website_url}", value = Configuration_BSO.GetCustomConfig("url.application")
            });
            listToParse.Add(new eMail_KeyValuePair()
            {
                key = "{body}", value = body
            });

            email.Subject = subject;
            email.Body    = email.ParseTemplate(Properties.Resources.template_NotifyWorkflow, listToParse);
            email.Send();
        }
Beispiel #3
0
        /// <summary>
        /// Send mails for a workflow
        /// </summary>
        /// <param name="email"></param>
        /// <param name="title"></param>
        /// <param name="subject"></param>
        /// <param name="body"></param>
        private void sendMail(eMail email, string title, string subject, string body)
        {
            var listToParse = new List <eMail_KeyValuePair>();

            List <string> grpCodes = new List <string>();

            grpCodes = DTO.GroupCodes.Select(s => (string)s.GrpCode).ToList();

            string grouplist = grpCodes.Any() ? String.Join(", ", grpCodes) : Label.Get("static.all-groups");

            listToParse.Add(new eMail_KeyValuePair()
            {
                key = "{title}", value = title
            });
            listToParse.Add(new eMail_KeyValuePair()
            {
                key = "{subject}", value = subject
            });
            listToParse.Add(new eMail_KeyValuePair()
            {
                key = "{body}", value = body
            });
            listToParse.Add(new eMail_KeyValuePair()
            {
                key = "{received-by}", value = string.Format(Label.Get("label.timezone", Configuration_BSO.GetCustomConfig(ConfigType.global, "language.iso.code")), grouplist)
            });
            listToParse.Add(new eMail_KeyValuePair()
            {
                key = "{website_name}", value = Configuration_BSO.GetCustomConfig(ConfigType.global, "title")
            });
            listToParse.Add(new eMail_KeyValuePair()
            {
                key = "{website_url}", value = Configuration_BSO.GetCustomConfig(ConfigType.global, "url.application")
            });
            listToParse.Add(new eMail_KeyValuePair()
            {
                key = "{image_source}", value = Configuration_BSO.GetCustomConfig(ConfigType.global, "url.logo")
            });
            listToParse.Add(new eMail_KeyValuePair()
            {
                key = "{datetime_label}", value = Label.Get("label.date-time", Configuration_BSO.GetCustomConfig(ConfigType.global, "language.iso.code"))
            });
            listToParse.Add(new eMail_KeyValuePair()
            {
                key = "{date_format}", value = Label.Get("label.date-format", Configuration_BSO.GetCustomConfig(ConfigType.global, "language.iso.code"))
            });
            listToParse.Add(new eMail_KeyValuePair()
            {
                key = "{timezone}", value = Label.Get("label.timezone", Configuration_BSO.GetCustomConfig(ConfigType.global, "language.iso.code"))
            });


            email.Subject = subject;
            email.Body    = email.ParseTemplate(Properties.Resources.template_GroupMessage, listToParse);
            email.Send();
        }
Beispiel #4
0
        /// <summary>
        /// Send mails for a workflow
        /// </summary>
        /// <param name="email"></param>
        /// <param name="title"></param>
        /// <param name="subject"></param>
        /// <param name="body"></param>
        private void sendMail(eMail email, string title, string subject, string body)
        {
            BBCode bbc = new BBCode();

            body = bbc.Transform(body, true);
            var listToParse = new List <eMail_KeyValuePair>();

            listToParse.Add(new eMail_KeyValuePair()
            {
                key = "{title}", value = title
            });
            listToParse.Add(new eMail_KeyValuePair()
            {
                key = "{subject}", value = subject
            });
            listToParse.Add(new eMail_KeyValuePair()
            {
                key = "{website_name}", value = Configuration_BSO.GetCustomConfig(ConfigType.global, "title")
            });
            listToParse.Add(new eMail_KeyValuePair()
            {
                key = "{website_url}", value = Configuration_BSO.GetCustomConfig(ConfigType.global, "url.application")
            });
            listToParse.Add(new eMail_KeyValuePair()
            {
                key = "{body}", value = body
            });
            listToParse.Add(new eMail_KeyValuePair()
            {
                key = "{image_source}", value = Configuration_BSO.GetCustomConfig(ConfigType.global, "url.logo")
            });
            listToParse.Add(new eMail_KeyValuePair()
            {
                key = "{datetime_label}", value = Label.Get("label.date-time", Configuration_BSO.GetCustomConfig(ConfigType.global, "language.iso.code"))
            });
            listToParse.Add(new eMail_KeyValuePair()
            {
                key = "{date_format}", value = Label.Get("label.date-format", Configuration_BSO.GetCustomConfig(ConfigType.global, "language.iso.code"))
            });
            listToParse.Add(new eMail_KeyValuePair()
            {
                key = "{timezone}", value = Label.Get("label.timezone", Configuration_BSO.GetCustomConfig(ConfigType.global, "language.iso.code"))
            });
            listToParse.Add(new eMail_KeyValuePair()
            {
                key = "{reason}", value = Label.Get("workflow.reason", Configuration_BSO.GetCustomConfig(ConfigType.global, "language.iso.code"))
            });

            email.Subject = subject;
            email.Body    = email.ParseTemplate(Properties.Resources.template_NotifyWorkflow, listToParse);
            email.Send();
        }
        /// <summary>
        /// Builds an email based on the template
        /// </summary>
        /// <param name="email"></param>
        /// <param name="title"></param>
        /// <param name="subject"></param>
        /// <param name="body"></param>
        /// <param name="salutationRecipient"></param>
        private bool sendMail(eMail email, string title, string subject, string body, string salutationRecipient)
        {
            var listToParse = new List <eMail_KeyValuePair>();


            listToParse.Add(new eMail_KeyValuePair()
            {
                key = "{title}", value = title
            });
            listToParse.Add(new eMail_KeyValuePair()
            {
                key = "{subject}", value = subject
            });
            listToParse.Add(new eMail_KeyValuePair()
            {
                key = "{salutation}", value = salutationRecipient
            });
            listToParse.Add(new eMail_KeyValuePair()
            {
                key = "{body}", value = body
            });
            listToParse.Add(new eMail_KeyValuePair()
            {
                key = "{website_name}", value = Configuration_BSO.GetCustomConfig(ConfigType.global, "title")
            });
            listToParse.Add(new eMail_KeyValuePair()
            {
                key = "{website_url}", value = Configuration_BSO.GetCustomConfig(ConfigType.global, "url.application")
            });
            listToParse.Add(new eMail_KeyValuePair()
            {
                key = "{image_source}", value = Configuration_BSO.GetCustomConfig(ConfigType.global, "url.logo")
            });
            listToParse.Add(new eMail_KeyValuePair()
            {
                key = "{datetime_label}", value = Label.Get("label.date-time", Configuration_BSO.GetCustomConfig(ConfigType.global, "language.iso.code"))
            });
            listToParse.Add(new eMail_KeyValuePair()
            {
                key = "{date_format}", value = Label.Get("label.date-format", Configuration_BSO.GetCustomConfig(ConfigType.global, "language.iso.code"))
            });
            listToParse.Add(new eMail_KeyValuePair()
            {
                key = "{timezone}", value = Label.Get("label.timezone", Configuration_BSO.GetCustomConfig(ConfigType.global, "language.iso.code"))
            });


            email.Subject = subject;
            email.Body    = email.ParseTemplate(Properties.Resources.template_NotifyChannelSubscription, listToParse);
            return(email.Send());
        }
        /// <summary>
        /// Execute
        /// </summary>
        /// <returns></returns>
        protected override bool Execute()
        {
            if (Common.FirebaseId == null && SamAccountName == null)
            {
                Response.error = Label.Get("error.authentication");
                return(false);
            }

            using (eMail email = new eMail())
            {
                string Body    = "";
                string Subject = "";

                Body          = Label.Get("email.body.subscription-notification", DTO.LngIsoCode);
                Subject       = Label.Get("email.subject.subscription-notification", DTO.LngIsoCode);
                email.Body    = Body;
                email.Subject = Subject;

                // Get user from FirebaseId
                Subscriber_BSO sbso = new Subscriber_BSO();
                var            user = sbso.GetSubscribers(Ado, Common.FirebaseId);

                if (user.FirstOrDefault() == null)
                {
                    Log.Instance.Debug("Cannot send notification because email address is null");
                    Response.error = Label.Get("error.notification");
                    return(false);
                }

                // Get email address from user
                string emailAddress = user.FirstOrDefault().CcnEmail;
                email.To.Add(emailAddress);
                Log.Instance.Debug($"Send notification to {emailAddress}");
                email.Send();
            }
            return(true);
        }
        /// <summary>
        /// Send mails for a workflow
        /// </summary>
        /// <param name="email"></param>
        /// <param name="title"></param>
        /// <param name="subject"></param>
        /// <param name="body"></param>
        private void sendMail(eMail email, string title, string subject, string body)
        {
            var listToParse = new List <eMail_KeyValuePair>();

            List <string> grpCodes = new List <string>();

            grpCodes = DTO.GroupCodes.Select(s => (string)s.GrpCode).ToList();

            listToParse.Add(new eMail_KeyValuePair()
            {
                key = "{title}", value = title
            });
            listToParse.Add(new eMail_KeyValuePair()
            {
                key = "{subject}", value = subject
            });
            listToParse.Add(new eMail_KeyValuePair()
            {
                key = "{body}", value = body
            });
            listToParse.Add(new eMail_KeyValuePair()
            {
                key = "{grouplist}", value = grpCodes.Any() ? String.Join(", ", grpCodes) : Label.Get("static.all-groups")
            });
            listToParse.Add(new eMail_KeyValuePair()
            {
                key = "{website_name}", value = Configuration_BSO.GetCustomConfig("title")
            });
            listToParse.Add(new eMail_KeyValuePair()
            {
                key = "{website_url}", value = Configuration_BSO.GetCustomConfig("url.application")
            });

            email.Subject = subject;
            email.Body    = email.ParseTemplate(Properties.Resources.template_GroupMessage, listToParse);
            email.Send();
        }
Beispiel #8
0
        internal static void SendLoginTemplateEmail(string subject, List <string> addressTo, string header, string content, string footer, string subHeader, string lngIsoCode, List <string> addressCc = null, List <string> addressBcc = null)
        {
            using (eMail email = new eMail())
            {
                email.Subject = subject;
                foreach (string to in addressTo)
                {
                    email.To.Add(to);
                }
                if (addressCc != null)
                {
                    foreach (string cc in addressCc)
                    {
                        email.CC.Add(cc);
                    }
                }
                if (addressBcc != null)
                {
                    foreach (string bcc in addressBcc)
                    {
                        email.Bcc.Add(bcc);
                    }
                }

                var listToParse = new List <eMail_KeyValuePair>();

                string body = header + Environment.NewLine + content + Environment.NewLine + footer;

                listToParse.Add(new eMail_KeyValuePair()
                {
                    key = "{header}", value = header
                });
                listToParse.Add(new eMail_KeyValuePair()
                {
                    key = "{sub_header}", value = subHeader
                });
                listToParse.Add(new eMail_KeyValuePair()
                {
                    key = "{content}", value = content
                });
                listToParse.Add(new eMail_KeyValuePair()
                {
                    key = "{footer}", value = footer
                });
                listToParse.Add(new eMail_KeyValuePair()
                {
                    key = "{subject}", value = subject
                });
                listToParse.Add(new eMail_KeyValuePair()
                {
                    key = "{image_source}", value = Configuration_BSO.GetCustomConfig(ConfigType.global, "url.logo")
                });
                listToParse.Add(new eMail_KeyValuePair()
                {
                    key = "{datetime_label}", value = Label.Get("label.date-time", lngIsoCode)
                });
                listToParse.Add(new eMail_KeyValuePair()
                {
                    key = "{date_format}", value = Label.Get("label.date-format", lngIsoCode)
                });
                listToParse.Add(new eMail_KeyValuePair()
                {
                    key = "{timezone}", value = Label.Get("label.timezone", lngIsoCode)
                });


                email.Body = email.ParseTemplate(Properties.Resources.template_Login, listToParse);
                try
                {
                    email.Send();
                }
                catch (Exception ex)
                {
                    Log.Instance.Error("Email failure: " + ex.Message);
                }
            }
        }