Пример #1
0
    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);
        }
    }
Пример #2
0
    public bool SendEmail(ConfirmationEmailTemplate email)
    {
        var smtp = new SmtpClient();

        smtp.Host = Utility.EmailConfiguration.SmtpServer;// Example: "smtp.gmail.com";

        smtp.Port           = 587;
        smtp.EnableSsl      = true;
        smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
        //smtp.UseDefaultCredentials = true;
        smtp.Credentials = new System.Net.NetworkCredential(Utility.EmailConfiguration.UserName, Utility.EmailConfiguration.Password);

        var    mail      = new MailMessage();
        string emailFrom = email.EmailFrom;

        string bodyContent = email.EmailBodyTemplate;

        mail.From = new MailAddress(emailFrom, "Pollinator - Share Map");
        mail.ReplyToList.Add(new MailAddress(emailFrom, "Pollinator - Share Map"));
        mail.Priority = MailPriority.High;


        string[] emailAddresses = email.EmailTo.Split(new char[] { ',', ';' });
        foreach (string address in emailAddresses)
        {
            mail.To.Add(address);
        }

        mail.Subject    = email.Subject;
        mail.Body       = bodyContent;
        mail.IsBodyHtml = true;

        //mail.AlternateViews.Add(AlternateView.CreateAlternateViewFromString(bodyContent, null, MediaTypeNames.Text.Html));

        try
        {
            smtp.Send(mail);
        }
        catch (Exception ex)
        {
            Logger.Error(typeof(AsyncWebRequest).Name + ".SendEmail()", ex);
            return(false);
        }

        return(true);
    }
    public bool SendEmail(ConfirmationEmailTemplate email)
    {
        var smtp = new SmtpClient();
        smtp.Host = Utility.EmailConfiguration.SmtpServer;// Example: "smtp.gmail.com";

        smtp.Port = 587;
        smtp.EnableSsl = true;
        smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
        //smtp.UseDefaultCredentials = true;
        smtp.Credentials = new System.Net.NetworkCredential(Utility.EmailConfiguration.UserName, Utility.EmailConfiguration.Password);

        var mail = new MailMessage();
        string emailFrom = email.EmailFrom;

        string bodyContent = email.EmailBodyTemplate;

        mail.From = new MailAddress(emailFrom, "Pollinator - Share Map");
        mail.ReplyToList.Add(new MailAddress(emailFrom, "Pollinator - Share Map"));
        mail.Priority = MailPriority.High;

        string[] emailAddresses = email.EmailTo.Split(new char[]{',',';'});
        foreach(string address in emailAddresses)
        {
            mail.To.Add(address);
        }

        mail.Subject = email.Subject;
        mail.Body = bodyContent;
        mail.IsBodyHtml = true;

        //mail.AlternateViews.Add(AlternateView.CreateAlternateViewFromString(bodyContent, null, MediaTypeNames.Text.Html));

        try
        {
            smtp.Send(mail);
        }
        catch (Exception ex)
        {
            Logger.Error(typeof(AsyncWebRequest).Name + ".SendEmail()", ex);
            return false;
        }

        return true;
    }
Пример #4
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);
        }
    }
Пример #5
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

        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}", "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 = adminEmail;
            emailTemplate.EmailFrom = Utility.EmailConfiguration.WebMasterEmail;
            emailTemplate.Subject = "Thank you for registering with S.H.A.R.E!";
            emailTemplate.EmailBodyTemplate = content;

            return emailTemplate;
        }
    }
    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
        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("{RegisterName}", userInfo.FirstName);
            content = content.Replace("{UserName}", System.Web.Security.Membership.GetUser(userInfo.UserId).UserName);
            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");

            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 = membership.Email;// "[email protected];[email protected]"; //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;
        }
    }