Sending Email

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a requirement, where a user will click on a button, and the Email new
message window will open up. The app will fill in the To: column from a
database.

I have gotten it to work, by using

Dim sEmail As String = "mailto:"
sEmail = sEmail & _
"(e-mail address removed);[email protected]"
HttpContext.Current.Response.Redirect(sEmail)

However, the web browser then gets a page cannot be displayed error. How do
I open the new mail window?

I also have the same issue with other web pages. How can I dynamically open
a web page in a new browser window?
 
Hi Dear Leonard,

You can send the fill in the To: column filled up from the database to a
new webpage in several ways
I will show you two ways.

1. Using QueryString - If the sEmail is not a secret data.
2. Using the Session - If the sEmail is a secret data.

for both the ways build the sEmail as you have shown (but you have not
showing filling from the database. But anyway, that you can do it)

Dim sEmail As String = "mailto:"
sEmail = sEmail & _
"(e-mail address removed);[email protected]"

''To Send the QueryString to the Second form
''===========================


HttpContext.Current.Response.Redirect(WebForm2.aspx?mailtoaddress_QueryString=" + sEmail)

mailtoaddress_QueryString - change this name as per your requirement.

Whatever you send through sEmail will get attached to the Redirect URL as a
QueryString

To use the QueryString in the Second form
============================
I have show populating in the TextBox and Lable, or using in Response.Write.
You can use as you like

TextBox1.Text=Request.QueryString["mailtoaddress_QueryString"].ToString()
Label1.Text=Request.QueryString["mailtoaddress_QueryString"].ToString()

Response.Write("<b><Font color=blue>Mail to Address Using
QueryString:</Font></b>" +Request.QueryString["mailtoaddress_QueryString"])

************************************************************

II Way - Using Session
====
In the 1st WebPage
============

Dim sEmail As String = "mailto:"
sEmail = sEmail & _
"(e-mail address removed);[email protected]"

Session["mailtoaddress"]=sEmail;

In the 2nd WebPage
=============

TextBox1.Text=Session["mailtoaddress"]).ToString()

Label1.Text=Session["mailtoaddress"]).ToString()

Response.Write("<b><Font color=blue>Mail to Address Using
QueryString:</Font></b>" + Session["mailtoaddress"])

For Anything and Everything, please let me know

bye
Venkat_KL
 
Back
Top