user2234111 user2234111 - 2 months ago 6
C# Question

insert a link in to a email send using c#

i develop a program to send emails automatically using c#, and i want to insert a link to a web site to that email. how can i do it?

public bool genarateEmail(String from, String to, String cc, String displayName, String password, String subjet, String body)
{
bool EmailIsSent = false;

MailMessage m = new MailMessage();
SmtpClient sc = new SmtpClient();
try
{
m.From = new MailAddress(from, displayName);
m.To.Add(new MailAddress(to, displayName));
m.CC.Add(new MailAddress("xxx@gmail.com", "Display name CC"));

m.Subject = subjet;
m.IsBodyHtml = true;
m.Body = body;


sc.Host = "smtp.gmail.com";
sc.Port = 587;
sc.Credentials = new
System.Net.NetworkCredential(from, password);
sc.EnableSsl = true;
sc.Send(m);

EmailIsSent = true;

}
catch (Exception ex)
{
EmailIsSent = false;
}

return EmailIsSent;
}


i want to send a link through this email. how should i add it to email?

Answer
 String body = "Your message : <a href='http://www.example.com'></a>"
 m.Body = body;
Comments