i have designed a mailer which contains a html page as mail body. There are certain links in the html page. There can be any number of links and i don't know about them. since everything inside a html page is considered a string. What i want is whenever i click on a particular link, that link should be replaced with a link to an intermediate page where i want the parameter values through query string. Here is my code-
protected void btnSubmit_Click(object sender, EventArgs e)
{
{
SendHTMLMail();
}
void SendHTMLMail()
{
StreamReader reader = new StreamReader(Server.MapPath("~/index1.html"));
string readFile = reader.ReadToEnd();
string myString = "http";
myString = readFile;
myString = myString.Replace(@"??", @"http://localhost:60488/url.aspx?" + "sender=" + Server.UrlEncode(this.txtUsername.Text) + "&reciever=" + Server.UrlEncode(this.txtTo.Text));
MailMessage Msg = new MailMessage();
Msg.From = new MailAddress(txtUsername.Text);
Msg.To.Add(txtTo.Text);
Msg.Subject = txtSubject.Text;
Msg.Body = myString.ToString();
Msg.IsBodyHtml = true;
if (fuAttachment.HasFile)
{
string FileName = Path.GetFileName(fuAttachment.PostedFile.FileName);
Msg.Attachments.Add(new Attachment(fuAttachment.PostedFile.InputStream, FileName));
}
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.Port = 587;
smtp.UseDefaultCredentials = false;
smtp.Credentials = new System.Net.NetworkCredential(txtUsername.Text, txtpwd.Text);
smtp.EnableSsl = true;
smtp.Send(Msg);
Msg = null;
ClientScript.RegisterStartupScript(GetType(), "alert", "alert('Email sent.');", true);
}
}
in this block-
StreamReader reader = new StreamReader(Server.MapPath("~/index1.html"));
string readFile = reader.ReadToEnd();
string myString = "http";
myString = readFile;
myString = myString.Replace(@"??", @"http://localhost:60488/url.aspx?" + "sender=" + Server.UrlEncode(this.txtUsername.Text) + "&reciever=" + Server.UrlEncode(this.txtTo.Text));
what i tried is considered the url as a string and given it an initial value "http". Since i don't know anything after http as it can be any link for example - http://example.co.in or https://example.com i want to replace the link with the link of my intermediate page and also want to know the complete link after http and send that link name in a query string