?
Solved

Email Address hyperlinks?

Posted on 2003-03-25
15
Medium Priority
?
161 Views
Last Modified: 2010-04-01
Hello

Im wondering if anyone can help me with this... Im using ms access as my database with jsp. I have a column that holds email addresses, when I search for a particular person, and they are retreived, how will i be able to click on the email address, when the record comes up and open it up in my OutLook Express. so that the user can type in a message if they want to. Does the hyperlink have to set in Access or is the a way of coding it in jsp.

Please help
0
Comment
Question by:gotchi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 6
15 Comments
 
LVL 19

Expert Comment

by:cheekycj
ID: 8202799
you can use the html tag mailto

Now if the user has Outlook configured as their default email program it will be launched otherwise their default email prog will be launched.

<%
Connection conn = null;
// .. setup conn here
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("select email_address_column from your_table");
while(rs.next()) { %>
  <a href="mailto:<%=rs.getString("email_address_column")%>">=rs.getString("email_address_column")%></a>
<% } %>
<%
rs.close();
stmt.close();
conn.close();
%>

CJ
0
 

Author Comment

by:gotchi
ID: 8204438
That sort of worked, it did open in outlook express but i have a table, so when the values are returned i.e name, surname and the email address i shud be able to click on the email address. At the moment when it runs....

=RS.getString("EmailAddress" shows at the top of my table, and my email column is blank... my code is below

<table BORDER WIDTH="100%" >
<tr>
   <td><b>First Name</b></td>
   <td><b>Surname</b></td>
   <td><b>Address</b></td>
   <td><b>Phone number</b></td>
   <td><b>Email Address</b></td>
</tr>
<%
while(RS.next())
     {
%>
     <tr>
     <td><%=RS.getString("FirstName") %></td>
     <td><%=RS.getString("Surname") %></td>
     <td><%=RS.getString("Address") %></td>
     <td><%=RS.getString("Number") %></td>
     <a href="mailto:<%=RS.getString("EmailAddress")%>">=RS.getString("EmailAddress")</a>
</tr>

   

<% } %>
<%
   RS.close();

connection.close();
0
 
LVL 19

Expert Comment

by:cheekycj
ID: 8204499
try this:

=RS.getString("EmailAddress" shows at the top of my table, and my email column is blank... my code is below

<table BORDER WIDTH="100%" >
<tr>
  <td><b>First Name</b></td>
  <td><b>Surname</b></td>
  <td><b>Address</b></td>
  <td><b>Phone number</b></td>
  <td><b>Email Address</b></td>
</tr>
<%
while(RS.next())
    {
    String emailAddress = RS.getString("EmailAddress");
%>
    <tr>
    <td><%=RS.getString("FirstName") %></td>
    <td><%=RS.getString("Surname") %></td>
    <td><%=RS.getString("Address") %></td>
    <td><%=RS.getString("Number") %></td>
    <a href="mailto:<%=emailAddress%>"><%=emailAddress%></a>
</tr>

 

<% } %>
<%
  RS.close();

connection.close();

CJ
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:gotchi
ID: 8204942
hi,
we are getting a lot closer now:) The email address is showing now,but it is still sitting on top of the table. I have tried to move the code about, but it wont budge! :)
0
 
LVL 19

Expert Comment

by:cheekycj
ID: 8205005
I don't understand that it is on top of the page and it won't budge?

Are you sure your changes in the JSP are showing up?

delete your work directory and then try accessing the page.

CJ
0
 

Author Comment

by:gotchi
ID: 8205173
what I mean is whilst all the returned values i.e. name, surname etc, are in each of their individual columns, the email address column is blank, beacuse the email address returned is at the top of the table and not in the actual column.
0
 
LVL 19

Expert Comment

by:cheekycj
ID: 8205384
missing the wrapping <td> I think :-)

=RS.getString("EmailAddress" shows at the top of my table, and my email column is blank... my code is below

<table BORDER WIDTH="100%" >
<tr>
 <td><b>First Name</b></td>
 <td><b>Surname</b></td>
 <td><b>Address</b></td>
 <td><b>Phone number</b></td>
 <td><b>Email Address</b></td>
</tr>
<%
while(RS.next())
   {
   String emailAddress = RS.getString("EmailAddress");
%>
   <tr>
   <td><%=RS.getString("FirstName") %></td>
   <td><%=RS.getString("Surname") %></td>
   <td><%=RS.getString("Address") %></td>
   <td><%=RS.getString("Number") %></td>
   <td><a href="mailto:<%=emailAddress%>"><%=emailAddress%></a></td>
</tr>

 

<% } %>
<%
 RS.close();

connection.close();

CJ
0
 

Expert Comment

by:sathit_p16
ID: 8215910
I think previous comment is true but forgot to close tag table

 
<table BORDER WIDTH="100%" >
<tr>
<td><b>First Name</b></td>
<td><b>Surname</b></td>
<td><b>Address</b></td>
<td><b>Phone number</b></td>
<td><b>Email Address</b></td>
</tr>
<%
while(RS.next())
  {
  String emailAddress = RS.getString("EmailAddress");
%>
  <tr>
  <td><%=RS.getString("FirstName") %></td>
  <td><%=RS.getString("Surname") %></td>
  <td><%=RS.getString("Address") %></td>
  <td><%=RS.getString("Number") %></td>
  <td><a href="mailto:<%=emailAddress%>"><%=emailAddress%></a></td>
</tr>



<% } %>
<%
RS.close();
connection.close();
%>
</table>

0
 
LVL 19

Expert Comment

by:cheekycj
ID: 8217952
so does it work now?

CJ
0
 

Author Comment

by:gotchi
ID: 8219007
nope that didnt make a difference, whether the tag was there or not :( the email address is still not in the email column.
What now?

gotchi
0
 
LVL 19

Expert Comment

by:cheekycj
ID: 8219066
can you post your current code.

Thanx,
CJ
0
 

Author Comment

by:gotchi
ID: 8219213
This is my code as it currently stands

String sql = ""
   + " SELECT   FirstName, LastName, Address, PhoneNumber, EmailAddress "
   + " FROM Employee"
   + " WHERE FirstName = '" + request.getParameter("FirstName") + "'"
   + " AND LastName = '" + request.getParameter("LastName") + "'";
   
java.sql.PreparedStatement statement = connection.prepareStatement(sql);
ResultSet RS = statement.executeQuery();
%>

<table BORDER WIDTH="100%" >
<tr>
   <td><b>First Name</b></td>
   <td><b>Surname</b></td>
   <td><b>Address</b></td>
   <td><b>Number</b></td>
   <td><b>Email Address</b></td>
</tr>
<%
while(RS.next())
     {
String EmailAddress = RS.getString("EmailAddress");
%>
     <tr>

     <td><%=RS.getString("FirstName") %></td>
     <td><%=RS.getString("LastName") %></td>
     <td><%=RS.getString("Address") %></td>
     <td><%=RS.getString("PhoneNumber") %></td>
     <a href="mailto:<%=EmailAddress%>"><%=EmailAddress%></a></td>
</tr>
0
 
LVL 19

Accepted Solution

by:
cheekycj earned 140 total points
ID: 8219537
I still see a missing starting <td> so try this:
<%
String sql = ""
  + " SELECT   FirstName, LastName, Address, PhoneNumber, EmailAddress "
  + " FROM Employee"
  + " WHERE FirstName = '" + request.getParameter("FirstName") + "'"
  + " AND LastName = '" + request.getParameter("LastName") + "'";
 
java.sql.PreparedStatement statement = connection.prepareStatement(sql);
ResultSet RS = statement.executeQuery();
%>

<table BORDER WIDTH="100%" >
<tr>
  <td><b>First Name</b></td>
  <td><b>Surname</b></td>
  <td><b>Address</b></td>
  <td><b>Number</b></td>
  <td><b>Email Address</b></td>
</tr>
<%
while(RS.next())
    {
String EmailAddress = RS.getString("EmailAddress");
%>
    <tr>

    <td><%=RS.getString("FirstName") %></td>
    <td><%=RS.getString("LastName") %></td>
    <td><%=RS.getString("Address") %></td>
    <td><%=RS.getString("PhoneNumber") %></td>
    <td><a href="mailto:<%=EmailAddress%>"><%=EmailAddress%></a></td>
</tr>
<% } %>
</table>

CJ
0
 

Author Comment

by:gotchi
ID: 8220492
Thanks

I was looking at the wrong tag the whole time, thinking to myself what is "cheekyci" going on about!!! But it was my mistake, so thanxxxx

I'll post some more problems later ;)
0
 
LVL 19

Expert Comment

by:cheekycj
ID: 8220523
glad I could help and thanx for the "A"

CJ
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is a fine trick which I've found useful many times, when you just don't want to accidentally run a batch script or the commands needs administrator rights.
This month, Experts Exchange’s free Course of the Month is focused on CompTIA IT Fundamentals.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question