I recently got a link on how to add logo to my email message sent to users.
But in my case, I want only logo to be in the html page and other texts will be in the code behind (C#).
Please I just need to add only logo and then the other texts and button will be inside the Button click event that sends the email.
here is what I tried and it did not work.
Page.html
<body>
<img src="images/Logo2.png" /><br /><br />
<div style="border: 0.5px solid #e9ebeb;">
Hello<b >{User}</b>,<br /><br />
</div>
</body>
C#
private string PopulateBody(string User, string labeladmin)
{
string body = string.Empty;
using (StreamReader reader = new StreamReader(Server.MapPath("~/MyMailPage.htm")))
{
body = reader.ReadToEnd();
}
body = body.Replace("{User}", User);
body = body.Replace("{labeladmin}", labeladmin);
return body;
}
protected void Button1_Click(object sender, EventArgs e)
{
string adminID = Label1.Text.ToString();
using (MailMessage mm = new MailMessage("help@mymail.com", Emailtxtbx.Text))
{
mm.Subject = "Registration";
string body = this.PopulateBody("just invited you to sign up and be part of the team;
body += "<br /><br /><a style='display: block; width: 200px; height: 35px; background: #32CD32;padding: 10px;font-family: Nunito; text-align:left; border-radius: 5px;color: white;font-weight: 700;text-decoration: none;' href = '"
+ Request.Url.AbsoluteUri.Replace("newmember", "NewUserSignup.aspx?Id=" + adminID) + "'>Register as Team Member</a>";
body += "<br /><br /><hr />";
body += "<br /><br />If you have questions regarding this invitation, kindly contact";
body += "<br />" + mailtext.Text;
mm.Body = body;
mm.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient();
smtp.Host = "relay-hosting.secureserver.net";
smtp.EnableSsl = false;
NetworkCredential NetworkCred = new NetworkCredential("help@mymail.com", "xxxxxxxx");
smtp.UseDefaultCredentials = true;
smtp.Credentials = NetworkCred;
smtp.Port = 25;
smtp.Send(mm);
Div1.Visible = true;
}
}