开发者

Sending an email with a link that will post the user to a particular page that i have got!

Basically, I can send the user emails. I tried to send him this:

MailMessage message = new MailMessage()
{
    Subject = "YOURGURU account",
    Body = "Thanks for joining our site. click th link below to validate your account"+
           "<br/>"+
           HttpContext.Current.Request.Url.Host
};

message.To开发者_开发知识库.Add(new MailAddress("makovetskiyd@yahoo.co.uk", "Some name"));
message.IsBodyHtml = true;
SmtpClient client = new SmtpClient();
client.EnableSsl = true;
client.Send(message);

Response.Redirect("CheckYourEmail.aspx");

The HttpContext.Current.Request.Url.Host function appears in the email as "localhost"..but I need it to appear like a real link..that I press and it redirects me. I use visual studio 2010


It seems that you are using

HttpContext.Current.Request.Url.Host

instead of HttpContext.Current.Request.Url

For your local dev environment you will be getting localhost, but when you deploy this to some web server, this would correctly update itself to the hosted web server url.

Ideally, you would have some path that would contain the querystring and then corresponding code in page load to validate and use the querystring.

Example:

<br/>"+HttpContext.Current.Request.Url.Host + @"/AccountValidate.aspx?id=SomeId"

Note: You could use the HttpContext.Current.Request.Url also and that would redirect you to the current page with querystring:

<br/>"+HttpContext.Current.Request.Url + "?id=SomeId"

And then in page load of AccountValidate.aspx or current page:

string id = Convert.ToString(Request.QueryString["id"]);
if(!string.IsNullOrEmpty(id))
... //Code here to inform the user of successful activation

The important point to consider is that you would need some way to know which user clicked on the activation link, and hence the query string would be of use.

Hope it helps!


I'm a bit confused, but I'll try to help anyway.

I think what you're trying to do is to simply include a link in your email that users can click and get to your site.

To do that you'll want to include an anchor tag in your email that points to your site, and instead of using the Host address, you will need to include the Request.Url, like so:

String.Format("<a href=\"{0}\">click here</a>",HttpContext.Current.Request.Url);


If using Outlook 2010, go to Home/New Item/Email Message Using/HTML

Then highlight the word you would like to be shown as a link and right click with your mouse and select Hyperlinlk. This will open up a box where you choose where your link should point to.

Once selected properly, your word should show as a link with a changed colour and underlined.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜