Ejemplo n.º 1
0
    protected void SendEmail(string emailAddress, String Title, string subscriber, string strURL)
    {
        SmtpClient smtp = new SmtpClient();

        string MailTemplate = Server.MapPath("~/EmailTemplates/contactlist.htm");

        string template = string.Empty;

        if (File.Exists(MailTemplate))
        {
            template = File.ReadAllText(MailTemplate);
        }

        template = template.Replace("<%strSubscriber%>", subscriber);
        template = template.Replace("<%strURL%>", strURL);

        System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage();

        msg.From = new MailAddress("your email address", "your email address name");

        msg.To.Add(emailAddress);
        msg.Subject = Title;

        String logo = Server.MapPath("~/EmailTemplates/images/interagency.jpg");

        System.Net.Mail.AlternateView htmlView = AlternateView.CreateAlternateViewFromString(template, null, "text/html");
        LinkedResource pic1 = new LinkedResource(logo, MediaTypeNames.Image.Jpeg);

        pic1.ContentId = "logo";
        htmlView.LinkedResources.Add(pic1);
        msg.AlternateViews.Add(htmlView);
        objEmail.EmailConfig(template, msg);
    }
Ejemplo n.º 2
0
    protected void SendEmail(string emailAddress, String Title, string fullname, string username, string password)
    {
        SmtpClient smtp = new SmtpClient();

        string MailTemplate = Server.MapPath("~/EmailTemplates/users.htm");

        string template = string.Empty;

        if (File.Exists(MailTemplate))
        {
            template = File.ReadAllText(MailTemplate);
        }
        template = template.Replace("<%strUserFullName%>", fullname);
        template = template.Replace("<%strUserName%>", username);
        template = template.Replace("<%strPassword%>", password);

        System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage();

        msg.From = new MailAddress("*****@*****.**", "Inter-Agency Coordination Lebanon");

        msg.To.Add(emailAddress);
        msg.Subject = Title;

        String logo = Server.MapPath("~/EmailTemplates/images/interagency.jpg");

        System.Net.Mail.AlternateView htmlView = AlternateView.CreateAlternateViewFromString(template, null, "text/html");
        LinkedResource pic1 = new LinkedResource(logo, MediaTypeNames.Image.Jpeg);

        pic1.ContentId = "logo";
        htmlView.LinkedResources.Add(pic1);
        msg.AlternateViews.Add(htmlView);
        objEmail.EmailConfig(template, msg);
    }