예제 #1
0
    public string sendToFriend(string _emails, string _aid)
    {
        string result = "fail";

        clsCommon objCom = new clsCommon();
        string toEmail = _emails;
        StringBuilder strBody = new StringBuilder();
        strBody.Append("<br />");
        strBody.Append("<br />");
        strBody.Append("<h3>Hi!</h3>");
        strBody.Append("<br />");
        strBody.Append("There is alert on brdhc hospital. Click <a href='www.brdhchumber.com/alerts.aspx?aid=" + _aid + "'>Here</a> to check.");
        strBody.Append("<br />");
        string emailResult = objCom.sendEMail(toEmail, strBody.ToString(), "BRDHC Humber Alerts", true);
        if (string.IsNullOrEmpty(emailResult))
        {
            result = "pass";
        }
        else
        {
            result = emailResult;
        }

        return result;

    }
예제 #2
0
    protected void subPublish(object sender, EventArgs e)
    {
        // this will do the save or update but will also publish the alert. Then the alert will be published on the hoem page
        if (Page.IsValid)
        {
            MembershipUser user = Membership.GetUser();
            lblErr.Visible = true;
            try
            {
                string title = txtATitle.Text;
                string description = txtDesc.Text;
                objHAlerts.resetForPublish();
                // check for save and update
                if (_healthAlertId == null || _healthAlertId == Guid.Empty)
                {
                    _healthAlertId = Guid.NewGuid();
                    objHAlerts.saveHealthAlert(_healthAlertId, title, description, DateTime.Now, user.ProviderUserKey.ToString(), true);
                }
                else
                {
                    objHAlerts.updateHealthAlert(_healthAlertId, title, description, DateTime.Now, user.ProviderUserKey.ToString(), true);
                }
                lblErr.Text = "Health Alert published successfully.";
                clsCommon objCom = new clsCommon();
                string appName = WebConfigurationManager.AppSettings["appName"].ToString();

                // now if publish is successfull
                // then get all the emails of users from brdhc_AlertSubscribers
                // send each an email containing the alert as body part./
                List<sp_getAlertSubscribersResult> objEmails = objCom.sp_getAlertSubscribers(appName);

                foreach (sp_getAlertSubscribersResult record in objEmails)
                {
                    string fullName = "";
                    string toEmail = "";
                    string subscriberId = "";
                    StringBuilder strBody = new StringBuilder();
                    if (record.Name != null)
                    {
                        fullName = record.Name.ToString();
                    }
                    toEmail = record.Email.ToString();
                    subscriberId = record.UserId.ToString();

                    strBody.Append("<br />");
                    strBody.Append("<br />");
                    strBody.Append("<h3>Hi! " + fullName + "</h3>");
                    strBody.Append("<br />");
                    strBody.Append("<br />");
                    strBody.Append("We thought to notify you that there is an alert <a href='www.brdhchumber.com'>" + title + "</a>");
                    strBody.Append("<br />");
                    strBody.Append("Below is the description. Please look at it and forward this to others.");
                    strBody.Append("<br />");
                    strBody.Append("<br />");
                    strBody.Append(description);
                    strBody.Append("<br />");
                    strBody.Append("<b>Note: </b> If you do not want to get future emails <a href='http://www.brdhchumber.com/unsubscribe.aspx?uid=" + subscriberId + "'>unsubscribe<a/> here.");
                    strBody.Append("<br />");
                    strBody.Append("Wishing you very healthy life.");
                    strBody.Append("<br />");
                    strBody.Append("Team Humber");
                    string emailResult = objCom.sendEMail(toEmail, strBody.ToString(), "BRDHC Humber Alerts", true);
                }
            }
            catch (Exception ex)
            {
                lblErr.Text = ex.Message.ToString();
                clsCommon.saveError(ex);
            }
        }
    }