Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8488355
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T21:30:41+00:00 2026-06-10T21:30:41+00:00

I below code is to send email by reading the template html, and it

  • 0

I below code is to send email by reading the template html, and it works fine. But now my question is how to pass Salutation customerName from my .net code to the template at run time.

 StringBuilder strBlr = new StringBuilder();
            string strHTML = string.Empty;
            string strTempalteHtmlpath = string.Empty;

            //create the mail message
            MailMessage mail;

 string strFrom = ConfigurationSettings.AppSettings["fromAddressForBT"];
                string strSubject = "Thanks for choosing Email contact preference";
                mail = new MailMessage(strFrom, customerDetails.EmailId);

                mail.Subject = strSubject;

                //Read Html Template File Path
                strTempalteHtmlpath = Convert.ToString(ConfigurationSettings.AppSettings["TemplatePath"]);
                strHTML = File.ReadAllText(strTempalteHtmlpath);
                strBlr = strBlr.Append(strHTML);
                mail.Body = strBlr.ToString();
                mail.IsBodyHtml = true;


                //first we create the Plain Text part
                AlternateView plainView = AlternateView.CreateAlternateViewFromString(strBlr.ToString(), null, "text/plain");
                AlternateView htmlView = AlternateView.CreateAlternateViewFromString(strBlr.ToString(), null, "text/html");

 mail.AlternateViews.Add(plainView);
                mail.AlternateViews.Add(htmlView);

                //send the message
                SmtpClient smtpMail = new SmtpClient(ConfigurationSettings.AppSettings["smtpClient"]);
                smtpMail.Send(mail);

                mail.Dispose();

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T21:30:43+00:00Added an answer on June 10, 2026 at 9:30 pm

    This is code for sendemail button

        StreamReader sr = new StreamReader(Server.MapPath("Sendpage.htm"));
        string body = sr.ReadToEnd();         
        sr.Close();          
        body = body.Replace("#NameFamily#", txtNameFamily.Text);     
        body = body.Replace("#Email#", txtEmail.Text);        
        body = body.Replace("#Tellphone#", txtTellphone.Text);   
        body = body.Replace("#Text#", txtText.Text);       
        body = body.Replace("#Date#", DateTime.Now);        
        string Time = Convert.ToString(DateTime.Now.ToShortTimeString());    
        body = body.Replace("#Time#", Time);        
        SendMail("email that you want to send to it", body); 
    

    this is sendmail function code:

     private void SendMail(string To, string Body)
        {
            SmtpClient Mailing = new SmtpClient("mail.domain.com");
            MailMessage Message = new MailMessage();
            Message.From = new MailAddress("mail@domain.com", "Your name or company name");
            Message.Subject = "Subject";
            Message.SubjectEncoding = Encoding.UTF8;
            Message.IsBodyHtml = true;
            Message.BodyEncoding = Encoding.UTF8;
            Message.Body = Body;
            Message.To.Add(new MailAddress(To));
            Mailing.UseDefaultCredentials = false;
            NetworkCredential MyCredential = new NetworkCredential("mail@domain.com", "password");
            Mailing.Credentials = MyCredential; Mailing.Send(Message);
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using below code to send email it works fine most of the
Below code not work, but it's work fine for jsf1.2. Now the framework is
Below is my code snippet to send email: MySqlCommand cmdsd; MySqlConnection conn; string s23
I am trying to send email for forget password while trying the below code
I formatted sp_send_dbmail to send email in HTML format. But it is sending the
I am trying to use the below code to send email from asp.net(C#). using
I am using the below partial code to send email message to our client
I am trying to send an email using the below code: s = smtplib.SMTP(smtp.live.com,587,
hi in the code below i want to send the email (with input data
Trying to get Play! Framework to send an email with an attachment. Code below

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.