how to generate and email the page link to email id which is stored in database? Please help me . I have idea just about the http handler but how to use it i don't know! please help!

regards

mangesh5588

Dani AI

Generated

As clarified, the goal is to publish a response on its own URL and email that URL to the submitter. As noted, the concrete steps are what matters. A safe, maintainable pattern is: save the response, create a short-lived, unguessable token tied to that response, build an absolute link that includes the token, and email that link.

A minimal, practical workflow (generate token + send email):

var token = Guid.NewGuid().ToString("N");
// INSERT token, responseId, recipientEmail, expiry INTO ResponseTokens
var baseUrl = Request.Url.Scheme + "://" + Request.Url.Authority + Request.ApplicationPath.TrimEnd('/') + "/";
var link = baseUrl + "Response.aspx?t=" + token;

using(var msg = new System.Net.Mail.MailMessage("no-reply@domain.com", recipientEmail)) {
    msg.Subject = "Your response is ready";
    msg.IsBodyHtml = true;
    msg.Body = "View your response: <a href=\"" + link + "\">" + link + "</a>";
    using(var smtp = new System.Net.Mail.SmtpClient("smtp.server.com")) {
        smtp.Credentials = new System.Net.NetworkCredential("user","pass");
        smtp.EnableSsl = true;
        smtp.Send(msg);
    }
}

On the target page validate the token, check expiry and recipient (or single-use flag), then load and render the stored response. Example pseudocode:

var token = Request.QueryString["t"];
// SELECT responseId, expiry, recipient FROM ResponseTokens WHERE token=@token
// if not found or expired -> 404 / message
// else load response by responseId and render safely (HtmlEncode as needed)

Notes and gotchas: always send links over HTTPS, make tokens random (GUID or HMAC), set a short expiry and optionally mark tokens as used, sanitize response content to avoid XSS, and test SMTP settings (credentials, SSL, firewall). For rendering as a downloadable file you can use a page or an IHttpHandler — see the IHttpHandler docs for handlers and the System.Net.Mail docs for sending mail: IHttpHandler and MailMessage / SmtpClient. For modern apps consider using a maintained library like MailKit.

Recommended Answers

All 2 Replies

Your question is not quite clear. What do you want to do? Be more precise in order to get answered.

sir
i have datagridview in my asp.net page.

in datagridview there is columns id , subject, Emaill, query, response query.
id will be auto generated , subject, email id and query will be inserted by me. and also response query. Now i want to put this "response query" on a new page and send this page link to email id which is present in the gridview column. how i do this . i m sorry i could not explain at first time.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.