0

here is my code

System.Text.StringBuilder sb = new System.Text.StringBuilder();
        MailMessage message = new MailMessage("abc@gmail.com", txtEmailId.Text.Trim());
        message.Subject = "Auto email Test";
        message.IsBodyHtml = true;
        string str="http://localhost:55243/WebSiteTest/Accept.aspx?id=" +  txtEmailId.Text.Trim();
        string url = @"<a href="""+str+@""" target='_blank'";
        string str1 = "http://localhost:55243/WebSiteTest/Reject.aspx?id=" + txtEmailId.Text.Trim();
        string url1 = @"<a href=""" + str1 + @""" target='_blank'";
        message.Body = @"<html><body>Thanks For Showing interest in our site. please press "+ url + @">Accept</a>Or "+ url1+">Reject</a></body></html>";        
        SmtpClient client = new SmtpClient();     
        client.Credentials = new NetworkCredential("abc@gmail.com", "password");
        client.Send(message);

it redirects to the aspx page when link is clicked from mail received but as a new tab in browser. but i need to open the pages in small window that will open on the screen. any help!!!!!

Thanks in Advance.

  • Possible duplicate: http://stackoverflow.com/questions/12939928/make-a-link-open-a-new-window-not-tab – Uriil May 09 '14 at 10:47

2 Answers2

1

You can't do that. You would need javascript to open a window at a certain size, and e-mail cients - reasonably so - do not run javascript in e-mails.

Menno van den Heuvel
  • 1,851
  • 13
  • 24
0

I believe what you're seeing is a combination of markup and browser behavior. In particular, the anchor tags you're generating in the message body both contain the target="_blank" attribute. This tells the browser to open the content in a new window, but doesn't specify the size of the window, so it seems the browser is just opening a new tab in an already opened browser (if no browser is opened a new browser instance altogether is opened).

The behavior you're seeing is not unexpected. As Menno van den Heuvel mentioned, you do need JavaScript to give browsers explicit instructions on the window size. This w3schools.com link has some details on that if you're interested. But, again, as Menno van den Heuvel points out most email clients aren't well equipped to handle JavaScript.

Mike Atkisson
  • 581
  • 4
  • 9