How to send a custom design email recipients in c#

In this article, we have design a mail with color full div , with image and a click event . many time we get emails with beautiful design then we think that you we can create email with c# . we can also get the same think with html template.But here I have used the html tags in c# page.


Source Code:-

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Customemail.aspx.cs" Inherits="Customemail" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<html xmlns="">
<head id="Head1" runat="server">
    <form id="form1" runat="server">
    <br />
    <fieldset style="width: 400px;">
        <legend>Custom Email Design Example</legend>
                    <asp:TextBox ID="txtname" runat="server"></asp:TextBox>
                    <asp:TextBox ID="txtemail" runat="server"></asp:TextBox>
                <td align="center" colspan="2">
                    <asp:Button ID="btnsubmit" runat="server" Text="Submit" OnClick="btnsubmit_Click"
                        Font-Bold="True" Font-Size="Medium" Width="200px" />

Code behind (C#):-

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net.Mail;
using System.Net;

public partial class Customemail : System.Web.UI.Page
    protected void Page_Load(object sender, EventArgs e)

    protected void btnsubmit_Click(object sender, EventArgs e)
        using (MailMessage mm = new MailMessage("", txtemail.Text))

            mm.Subject = "Welcome To Code Solutions";

            string body = "<div style='background-color:#ba2323; ' align='center'>";
            body += "<p style='color:White; font-weight: bold;'>Hello  " + txtname.Text.Trim() + "</p>";
            body += "<br /> <p style='color:White;'>Thanks For visit our blog <p>";

            body += "<br/> <a style='display: block;height:70px;width: 250px;background: #34696f;border: 2px solid rgba(33, 68, 72, 0.59);color: rgba(0, 0, 0, 0.55);text-align: center;font: bold 1.2em/70px  Arial, Helvetica, Geneva, sans-serif;background: webkit-linear-gradient(top, #34696f, #2f5f63);background: -moz-linear-gradient(top, #34696f, #2f5f63); background: -o-linear-gradient(top, #34696f, #2f5f63);background: -ms-linear-gradient(top, #34696f, #2f5f63);background: linear-gradient(top, #34696f, #2f5f63); -webkit-border-radius: 50px;-khtml-border-radius: 50px;-moz-border-radius: 50px; border-radius: 50px;-webkit-box-shadow: 0 8px 0 #1b383b; -moz-box-shadow: 0 8px 0 #1b383b; box-shadow: 0 8px 0 #1b383b;  text-shadow: 0 2px 2px rgba(255, 255, 255, 0.2);' href = ''>Click Here</a>";
            body += "<br /><p style='color:White;'> We sincerely hope you have a great time using our services.</p><p style='color:White;'> For any feedback please write to us at</p> <br/>";

            body += "</div>";
            mm.Body = body;
            mm.IsBodyHtml = true;
            SmtpClient smtp = new SmtpClient();
            smtp.Host = "";
            smtp.EnableSsl = true;
            NetworkCredential NetworkCred = new NetworkCredential("", "password");
            smtp.UseDefaultCredentials = true;
            smtp.Credentials = NetworkCred;
            smtp.Port = 587;
            Response.Write("<Script>alert('Thanks for posting your resume us,our team will be contact you as soon as possible')</Script>");
            // Clear the textbox values
            txtname.Text = "";
            txtemail.Text = "";


How to send a custom design email recipients in c# How to send a custom design email recipients in c# Reviewed by NEERAJ SRIVASTAVA on 6:55:00 PM Rating: 5

1 comment:

Powered by Blogger.