How to send an Email with HTML Template using ASP.NET MVC 5MNmalusi ngubane10yAsked Nov 21, 2016, 3:49 AM EST3 answersShareLinkedInXCopy linkSavei want to create the html template that is going to appear to an email that is been sent.
How to send an Email with HTML Template using ASP.NET MVC 5MNmalusi ngubane10yAsked Nov 21, 2016, 3:49 AM EST3 answersShareLinkedInXCopy linkSavei want to create the html template that is going to appear to an email that is been sent.
Bikesh SrivastavaRank #108 · 20.3K reputation10y agoPosted Nov 21, 2016, 8:30 AM EST0Hi,Please refer below link.http://www.c-sharpcorner.com/UploadFile/33b051/sending-mail-with-html-template/ 0
Thiyagarajan ERank #2,329 · 607 reputation10y agoPosted Nov 21, 2016, 11:18 PM EST0Hi, Use the below code it will help you. C# Code://****************************Sending Mail*********************************** var UserName = "Thiyagu"; string ToEmailId = "[email protected]"; string body = string.Empty; using (StreamReader reader = new StreamReader(Server.MapPath("~/Views/Shared/MailTemplates/RegEmailTemp.html"))) { body = reader.ReadToEnd(); } body = body.Replace("{Content}", "Your Password Rest Completed Successfully If You Want to Reset Password Clik Bellow..."); body = body.Replace("{UserName}", UserName); body = body.Replace("{Title}", "PasswordChange"); body = body.Replace("{Description}", "This is Link To Change Your Password."); using (MailMessage mailMessage = new MailMessage()) { mailMessage.From = new MailAddress("[email protected]"); mailMessage.Subject = "test Mail"; mailMessage.IsBodyHtml = true; SmtpClient smtp = new SmtpClient(); smtp.Host = "Your Server Ip"; smtp.EnableSsl = false; smtp.UseDefaultCredentials = true; smtp.Credentials = new System.Net.NetworkCredential("[email protected]", "Password"); smtp.Port = 25; var UrlPath = "www.google.com"; body = body.Replace("{Url}", Url.Content(UrlPath)); mailMessage.Body = body; mailMessage.To.Add(ToEmailId); smtp.Send(mailMessage); } //*************Sending MAil*******************************************************In Your Html Template File: Hello , {Content} {Title} {Description} Thanks Find the uploaded Html Template file.0Rajeesh MenothRank #118 · 18.4K reputation10y agoPosted Nov 22, 2016, 12:14 AM EST0Hi, Please refer my article content : http://www.c-sharpcorner.com/UploadFile/2a6dc5/send-email-to-multiple-email-addresses-with-inline-image-usi/ 0Join to answer this questionEvery answer you publish earns 20 SHARP.Create free accountSign inKnow the answer?Answer a question in the forums and earn +20 SHARP for every answer.See unanswered questionsForumsTop experts01Arun PottiAnswers in the forums20answers02Tahir AnsariAnswers in the forums5answers03Kamlesh KumarAnswers in the forums5answers04Sam HobbsAnswers in the forums4answers05Željko PerićAnswers in the forums3answers?YouYour name goes here.Every answer: 20 SHARP.JoinFull leaderboard →2026DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Rajeesh MenothRank #118 · 18.4K reputation10y agoPosted Nov 22, 2016, 12:14 AM EST0Hi, Please refer my article content : http://www.c-sharpcorner.com/UploadFile/2a6dc5/send-email-to-multiple-email-addresses-with-inline-image-usi/ 0
Bikesh SrivastavaRank #108 · 20.3K reputationPosted Nov 21, 2016, 8:30 AM EST
Thiyagarajan ERank #2,329 · 607 reputationPosted Nov 21, 2016, 11:18 PM EST
Rajeesh MenothRank #118 · 18.4K reputationPosted Nov 22, 2016, 12:14 AM EST
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questionsTop experts