private ConfirmationEmailTemplate GetUserEmailTemplate(UserDetail userInfo, Pollinator.DataAccess.PolinatorInformation pollinator)
    {
        String path      = Request.PhysicalApplicationPath + "\\EmailTemplates\\RegisterEmail.html";
        Uri    uri       = HttpContext.Current.Request.Url;
        string webAppUrl = uri.GetLeftPart(UriPartial.Authority); //Return both host and port

        using (StreamReader reader = File.OpenText(path))
        {
            String content = reader.ReadToEnd();  // Load the content from your file...
            content = content.Replace("{RegisterName}", userInfo.FirstName);
            content = content.Replace("{UserType}", "PREMIUM");
            content = content.Replace("{ShareMapUrl}", webAppUrl + "/Pollinator/ShareMap.aspx");
            content = content.Replace("{OrganizationName}", pollinator.OrganizationName);
            content = content.Replace("{PhoneNumber}", userInfo.PhoneNumber);
            content = content.Replace("{LandscapeStreet}", pollinator.LandscapeStreet);
            content = content.Replace("{LandscapeCity}", pollinator.LandscapeCity);
            content = content.Replace("{LandscapeState}", pollinator.LandscapeState);
            content = content.Replace("{LandscapeZipcode}", pollinator.LandscapeZipcode);
            content = content.Replace("{PollinatorSize}", pollinator.PollinatorSize.ToString());
            content = content.Replace("{PollinatorType}", pollinator.PollinatorType.ToString());
            content = content.Replace("{LogonLink}", webAppUrl + "/Pollinator/Account/Login");

            var membership = System.Web.Security.Membership.GetUser(userInfo.UserId);

            var emailTemplate = new ConfirmationEmailTemplate();
            emailTemplate.EmailTo           = "*****@*****.**"; //DUMMY data, must replaced with real data of register user
            emailTemplate.EmailFrom         = Utility.EmailConfiguration.WebMasterEmail;
            emailTemplate.Subject           = "Thank you for registering with S.H.A.R.E!";
            emailTemplate.EmailBodyTemplate = content;

            return(emailTemplate);
        }
    }
    void btnRegister_Click(object sender, EventArgs e)
    {
        lblThankYouMessage.Text = "Thank you for registering pollinator information with Pollinator Partnership. An email has been sent to contact emails associated with your account. Please be patient; the delivery of email may be delayed. Remember to confirm that the email above is correct and to check your junk or spam folder or filter if you do not receive this email.";

        UserDetail userInfo = new UserDetail();
        var pollinator = new Pollinator.DataAccess.PolinatorInformation();

        //----------------NOTE: You have to supply the real data to replace this dummy data------------------
        userInfo.UserId = new Guid();
        userInfo.FirstName = "Truong";
        userInfo.PhoneNumber = "0904949821";

        pollinator.OrganizationName = "Natural Resources Conservation Service";
        pollinator.LandscapeStreet = "Duy Tan";
        pollinator.LandscapeCity = "Hanoi";
        pollinator.LandscapeState = "CA";
        pollinator.LandscapeZipcode = "01";
        pollinator.PollinatorSize = 1;
        pollinator.PollinatorType = 1;

        SendRegisterEmail(userInfo, pollinator);
    }
    public void SendRegisterEmail(UserDetail userInfo, Pollinator.DataAccess.PolinatorInformation pollinator)
    {
        var emails = new List <ConfirmationEmailTemplate>();

        var userEmailTemplate = GetUserEmailTemplate(userInfo, pollinator);

        emails.Add(userEmailTemplate);

        var Administrators = new List <string>();

        Administrators.Add("Truong"); //Dummy data, must be replaced with real Admin name

        foreach (var admin in Administrators)
        {
            string adminEmail = "*****@*****.**";//DUMMY data, must replaced with real data of Admin user

            var adminEmailTemplate = GetAdminEmailTemplate(admin, adminEmail, userInfo, pollinator);
            emails.Add(adminEmailTemplate);
        }

        Session["Emails"] = emails;
    }
    void btnRegister_Click(object sender, EventArgs e)
    {
        lblThankYouMessage.Text = "Thank you for registering pollinator information with Pollinator Partnership. An email has been sent to contact emails associated with your account. Please be patient; the delivery of email may be delayed. Remember to confirm that the email above is correct and to check your junk or spam folder or filter if you do not receive this email.";

        UserDetail userInfo   = new UserDetail();
        var        pollinator = new Pollinator.DataAccess.PolinatorInformation();

        //----------------NOTE: You have to supply the real data to replace this dummy data------------------
        userInfo.UserId      = new Guid();
        userInfo.FirstName   = "Truong";
        userInfo.PhoneNumber = "0904949821";

        pollinator.OrganizationName = "Natural Resources Conservation Service";
        pollinator.LandscapeStreet  = "Duy Tan";
        pollinator.LandscapeCity    = "Hanoi";
        pollinator.LandscapeState   = "CA";
        pollinator.LandscapeZipcode = "01";
        pollinator.PollinatorSize   = 1;
        pollinator.PollinatorType   = 1;

        SendRegisterEmail(userInfo, pollinator);
    }
Esempio n. 5
0
    //This function will send emails in background...
    public void SendRegisterEmail(UserDetail userInfo, Pollinator.DataAccess.PolinatorInformation pollinator)
    {
        phEmailTasks.Controls.Add(new LiteralControl("<iframe src='" + ResolveUrl("../AsyncSendEmail") + "' id='AsyncSendEmails' scrolling='no'></iframe>"));

        var emails = new List <ConfirmationEmailTemplate>();

        var userEmailTemplate = GetUserEmailTemplate(userInfo, pollinator);

        emails.Add(userEmailTemplate); //Add emailing for new user

        //var Administrators = new List<string>();
        //Administrators.Add("Truong"); //Dummy data, must be replaced with real Admin name

        foreach (var adminEmail in GetListAdmin())
        {
            var adminName          = adminEmail.Substring(0, adminEmail.IndexOf("@"));
            var adminEmailTemplate = GetAdminEmailTemplate(adminName, adminEmail, userInfo, pollinator);
            emails.Add(adminEmailTemplate); //Add emailing for Administrators
        }

        //Put them all in session object which will be retrieved in Async process running in background
        Session["Emails"] = emails;
    }
Esempio n. 6
0
    private ConfirmationEmailTemplate GetAdminEmailTemplate(string adminName, string adminEmail, UserDetail userInfo, Pollinator.DataAccess.PolinatorInformation pollinator)
    {
        String path      = Request.PhysicalApplicationPath + "\\EmailTemplates\\RegisterEmailAdmin.html";
        Uri    uri       = HttpContext.Current.Request.Url;
        string webAppUrl = uri.GetLeftPart(UriPartial.Authority); //Return both host and port
        string userType  = userInfo.MembershipLevel == 0 ? "NORMAL" : "PREMIUM";

        using (StreamReader reader = File.OpenText(path))
        {
            String content = reader.ReadToEnd();  // Load the content from your file...
            content = content.Replace("{AdminName}", adminName);
            content = content.Replace("{RegisterName}", userInfo.FirstName);
            content = content.Replace("{UserType}", userType);
            content = content.Replace("{ShareMapUrl}", webAppUrl + "/ShareMap");
            content = content.Replace("{OrganizationName}", pollinator.OrganizationName);
            content = content.Replace("{PhoneNumber}", userInfo.PhoneNumber);
            content = content.Replace("{LandscapeStreet}", pollinator.LandscapeStreet);
            content = content.Replace("{LandscapeCity}", pollinator.LandscapeCity);
            content = content.Replace("{LandscapeState}", pollinator.LandscapeState);
            content = content.Replace("{LandscapeZipcode}", pollinator.LandscapeZipcode);
            content = content.Replace("{PollinatorSize}", pollinator.PollinatorSize.ToString());
            content = content.Replace("{PollinatorType}", pollinator.PollinatorType.ToString());
            content = content.Replace("{LogonLink}", webAppUrl + "/ShareMap#login_form");
            content = content.Replace("{PollinatorLink}", webAppUrl + "/Admin/PollinatorInformation?user="******"{UserListLink}", webAppUrl + "/Admin/Users");

            var webAppPath = WebHelper.FullyQualifiedApplicationPath;
            content = content.Replace("{SiteLogo}", webAppPath + WebHelper.SiteLogo);

            var membership = System.Web.Security.Membership.GetUser(userInfo.UserId);

            var emailTemplate = new ConfirmationEmailTemplate();
            emailTemplate.EmailTo           = adminEmail;
            emailTemplate.EmailFrom         = Utility.EmailConfiguration.WebMasterEmail;
            emailTemplate.Subject           = "Thank you for registering with S.H.A.R.E!";
            emailTemplate.EmailBodyTemplate = content;

            return(emailTemplate);
        }
    }