Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mail to tag with database data for the body

Status
Not open for further replies.

arilvade

IS-IT--Management
Mar 17, 2005
32
US
How can I use the mailto: tag with an automatic input of data into the body with database data?

Thanks!
 

Check here what you can do with mailto. Although, if you have database access, you must have server side scripting access and I would strongly advise sending emails through the server side script rather than the mailto: protocol of a link.

___________________________________________________________
[small]Do something about world cancer today: PACT[/small]
 
Unfortunately we have no access to an e-mail server.

We are using Coldfusion for database access but CF doesn't have a mailto: tag fuction.

You said you must have server side scripting access; does this mean I have to use CF with my mailto: tag?
 
I am sure Coldfusion has the ability to send emails. I Googled and found the following: However, this would fall out of the scope of the current forum and I suggest you try your luck in forum232.

___________________________________________________________
[small]Do something about world cancer today: PACT[/small]
 
Coldfusion is for server side processing and can't be used to open the local users e-mail.

I would like to use the post command and insert the database info.
 
Why do you want to open local user's email? What if they don't have an email client set up?

___________________________________________________________
[small]Do something about world cancer today: PACT[/small]
 
This is are only option.

This is what I'm using now below, how can I use the post command instead?


<TR>
<TD align=center>

<FORM ACTION="mailto:testing.ctr@test.mil">
<input type="hidden" name="subject" value="Document Scan Request">
<TEXTAREA COLS="50" ROWS="8" NAME="Body">
Please scan the following document:
<CFOUTPUT QUERY="query" STARTROW=1 MAXROWS=1>
Task_ID:#trim(ti_id)#
Class:_#trim(ti_type)#-#trim(ti_class)#
Type:_#trim(ti_task)#
Number:_#trim(ti_num)#
Rev:_#trim(ti_rev)#_&nbsp;&nbsp;Increment:_#trim(ti_incr)#
Title:_#trim(ti_brief)#
</CFOUTPUT>
</TEXTAREA>
</TD>
</TR>
<br>
<TR>
<TD align=center><input type=submit value="Submit"></TD>
</TR>
</TABLE>
 
Have you asked how to send an email through CF in forum232? I still see that as a best option for you.

___________________________________________________________
[small]Do something about world cancer today: PACT[/small]
 
I agree. You won't be able to send the email using the client's email app, and use Coldfusion to add the information to the database at the same time.

And As Vragabond said, what happens if the user doesn't have a configured email client, or just closes the email window that opens? Answer: no email is sent.

Adobe has a nice example of how to send an email with Coldfusion here.


If you still can't do this, then there's no way of doing what you want short of using Javascript to send the form's information to a Coldfusion page to insert into the DB, and then submit the form normally.

But then this again falls out of the scope of this forum, and you should ask in the JS forum here:
forum216



----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
The whole process seems rather cumbersome to me.

Your visitor selects - somehow - a document from your CF-powered database, and you want them to put that information into an email and send it.

Is it possible to go about this another way? How about adding a table to your database to hold a list of requests - the user registers their request, which stores details of the document, the user and the date in the new table.

The people dealing with it can run a report on the table which lists all outstanding requests, and mark off the ones they've dealt with.

I think that's where you should be heading, if you need to go with the "send an email" approach as a stop-gap, do it server-side like the guys say.

-- Chris Hunt
Webmaster & Tragedian
Extra Connections Ltd
 
We have NO access to an e-mail server thanks to NMCI.
I don't want to mess with the database.
Our only option is to use the users e-mail.

The code above works but it adds plus signs in the spaces - all I need to do is to get rid of the plus signs in the "Document Scan Request" and "Please scan the following document", is there a characacter to insert between the words?

I think this can be done with the post command with the text/ option so it doesn't send an attachment, but I',m not sure how.

 
instead of spaces use %20

I agree with the rest of them though.

--
Tek-Tips Forums is Member Supported. Click Here to donate

<honk>*:O)</honk>

Tyres: Mine's a pint of the black stuff.
Mike: You can't drink a pint of Bovril.


 
Doesn't work:

<FORM ACTION="mailto:testing.ctr@test.mil">
<input type="hidden" name="subject" value="Document%20Scan Request">


<TD align=center><input type=submit value="Submit"></TD>
 
Does it have to be a form button?
Can you not use a normal link?

Code:
<a href="mailto:testing.ctr@test.mil?subject=Document%20Scan%20Request&body=Some%20text%20here>Mail link</a>

--
Tek-Tips Forums is Member Supported. Click Here to donate

<honk>*:O)</honk>

Tyres: Mine's a pint of the black stuff.
Mike: You can't drink a pint of Bovril.


 
If I don't use a form I don't get the database data.
 
OK, I don't know ColdFusion but it appears to me that all you are doing is making a database query and putting the resulting data inside a textarea element.

So instead of that, can't you add the text into the link as an additional parameter?

I'd put the data into a variable, perform a string replacement function on it to replace the spaces with %20 then form my link as mailto:test@domain.com?subject=My%20Subject&amp;body=Here%20is%20%my%20data

--
Tek-Tips Forums is Member Supported. Click Here to donate

<honk>*:O)</honk>

Tyres: Mine's a pint of the black stuff.
Mike: You can't drink a pint of Bovril.


 
I'm not sure how to do this:I'd put the data into a variable, perform a string replacement function.
I'm a beginner with programming.
 
Then you need to go to the Coldfusion Forum (as alluded to earlier) as we are now outside the scope of XHTML/CSS.

My best guess is that you put the bit of coldfusion code in the link tag like so.

Code:
<a href="mailto:test@mail.com?subject=Document&20Scan%20Request&amp;body=

[i]insert coldfusion code here and make sure all spaces are converted to %20[/i]

">Click to send request</a>

I will say though, that even though the above may accomplish what you are trying to do it's got to be the wrong way.
You should be creating the mail server side. If you don't have access to a mailserver and you are part of an organisation (military?) then you should try and arrange to be able to use one. Your project basically requires it.

What we've shown you here is a stop-gap but ultimately poor solution to what is really a very easy to solve problem.

--
Tek-Tips Forums is Member Supported. Click Here to donate

<honk>*:O)</honk>

Tyres: Mine's a pint of the black stuff.
Mike: You can't drink a pint of Bovril.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top