示例#1
0
        public ClsInstantchatyes SendEmailForInstantchat(int Userid)
        {
            ClsInstantchatyes SendEmailForInstantchat = new ClsInstantchatyes();

            using (IDbConnection con = new SqlConnection(ConnectionString))
            {
                if (con.State == ConnectionState.Closed)
                {
                    con.Open();
                }
                DynamicParameters parameters = new DynamicParameters();
                parameters.Add("@Userid", Userid);
                SendEmailForInstantchat = con.Query <ClsInstantchatyes>("GetUserDeatilforInsatchat", parameters, commandType: CommandType.StoredProcedure).FirstOrDefault();
            }
            return(SendEmailForInstantchat);
        }
示例#2
0
        public async Task SendEmailForInstantchat(ClsInstantchatyes result)
        {
            // string email_from = _config["FromEmail"];
            string email_to = "*****@*****.**";
            //string email_to = "*****@*****.**";
            //  string email_to = "*****@*****.**";
            // string email_to = "*****@*****.**";
            var body = new StringBuilder();

            body.AppendFormat("Dear Duty Counsellors,<br /><br />");
            body.AppendLine($"Please be advised that a client accessing the AccessChat service has identified that they are having thoughts of suicide of self-harm. Please reach out to them as soon as possible to provide support.<br />");
            body.AppendLine($"" + result.FullName + "<br />");
            body.AppendLine($"" + result.Phone + "<br />");
            if (result.City == null || result.City == "")
            {
                body.AppendLine($"" + result.State + "<br />");
            }
            else
            {
                body.AppendLine($"" + result.City + ", " + result.State + "<br />");
            }
            body.AppendLine($"The client has been advised to contact emergency services and/or Lifeline, however reaching out to them is part of our duty of care and our drive to look after people in need.<br />");
            body.AppendLine($"This is an automated message from the AccessChat system. Please do not reply.<br /><br />");
            body.AppendLine($"{regards}<br />");
            body.AppendLine($"{footerlink}");
            //body.AppendLine($"<img src='C:\\Users\\aspire\\Desktop\IMGBIN_android-google-play-iphone-app-store-png_6dzJ0xzB.png' alt='Girl in a jacket' width='500' height='600'>");
            var apiKey = _config.GetSection("EmailSendGridKey").Value;


            var client = new SendGridClient(apiKey);
            var msg    = new SendGridMessage()
            {
                From             = new EmailAddress(_riskemail, "AccessEAP Chat System (do not reply)"),
                Subject          = "ALERT: Please contact an at-risk client",
                PlainTextContent = "",
                HtmlContent      = body.ToString(),
            };

            msg.AddTo(new EmailAddress(email_to));

            var response = await client.SendEmailAsync(msg);
        }