I was taught how to add a logo to an email sent to users but I cannot really get this straight to work. I have been trying to add a logo to a mail message but could not. I have tried everything but it appears not working.
I am having error upon error on this. It shows that
There is no argument given that corresponds to the required formal parameter of ‘labeladmin’ of ‘Adnewuser.PopulateBody(string, string)’
protected void Page_Load(object sender, EventArgs e)
{
if (Session["user"] == null)
{
}
else
{
Label1.Visible = false;
labeladmin.Visible = false;
}
}
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)
{
if (!string.IsNullOrEmpty(Emailtxtbx.Text))
{
string adminID = Label1.Text.ToString();
using (MailMessage mm = new MailMessage("mymail@outlook.com", Emailtxtbx.Text))
{
mm.Subject = "Membership Registration";
string body = this.PopulateBody("Hello " + Emailtxtbx.Text.Trim() + ",<br /><br />");
body += "You have just been invited to join the " + labeladmin.Text + " team.";
body += "<br /><br />Please click the below button to sign up and join the " + labeladmin.Text + " team";
body += "<br /><br /><a style='display: block; width: 190px; height: 29px; background: #32CD32;padding: 9px;font-family: Nunito; text-align:center; 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 " + labeladmin.Text + " at";
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("mymail@outlook.com", "XXXXXXXXXX");
smtp.UseDefaultCredentials = true;
smtp.Credentials = NetworkCred;
smtp.Port = 25;
smtp.Send(mm);
Div1.Visible = true;
lblsuccess.Visible = true;
lblsuccess.Text = "Success";
lblsuccess.ForeColor = System.Drawing.Color.Green;
Div2.Visible = false;
Lblerror.Visible = false;
}
}
else
{
Div2.Visible = true;
Lblerror.Visible = true;
Lblerror.Text = "Please provide valid email address";
Lblerror.ForeColor = System.Drawing.Color.Black;
Div1.Visible = false;
lblsuccess.Visible = false;
}
}