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!

Beginner's Question 3

Status
Not open for further replies.

lck092580

Programmer
Jun 19, 2002
440
CA
Hello.. can anyone tell me how I can execute the mailto command once i gather information from a page?

Here's how it goes:

1. welcome.asp gathers information from the user.
2. once the user clicks submit welcome.asp page will pass all the information in the query string to send.asp.
3. send.asp will now take the query string put the appropriate body, subject, to.. mailto command and execute it thus opening the client's default email program.

I have all the processing stuff done just need to know how i can execute mailto.

Thanks.

T
 
I'm assuming you want the email sent without editing exactly how you created it in your send.asp. If so you will need to look into something like CDONTS to do it. There is a FAQ on processing a form, and sending it to a db and mailing it. Obviously you probably don't need the db portion, but the email portion ought to help you out.
-Tarwn ------------ My Little Dictionary ---------
Reverse Engineering - The expensive solution to not paying for proper documentation
 
when you say exucute the mailto what exactly do you mean. action="send.asp" will exucute it. or do you actually need the mailto code to be run like
Set Mailer = Server.CreateObject("SMTPsvg.Mailer")
Mailer.FromName = ""
Mailer.FromAddress = ""
Mailer.RemoteHost = ""
Mailer.AddRecipient ""
strMsgHeader = "" & vbCrLf
for each qryItem in Request.QueryString
strMsgInfo = strMsgInfo & qryItem & " - " & request.querystring(qryItem) & vbCrLf
Response.Write(&quot;<BR>&quot;)
next
strMsgFooter = vbCrLf & &quot;End of request&quot;
Mailer.BodyText = strMsgHeader & strMsgInfo & strMsgFooter
Not everything you type is understanding to others! Think about that before getting upset with a wrong answer to your question.

admin@onpntwebdesigns.com
 
Server.Execute &quot;&quot; Not everything you type is understanding to others! Think about that before getting upset with a wrong answer to your question.

admin@onpntwebdesigns.com
 
Wow.. thanks for the quick response guys.. really appreciate it. I ended up doing none of the above mentioned.

Tarwn: Yeah i looked into cdonts and even got the code to send email thru IIS's smtp service but ended up changing it cuz I didn't want the mail to be send from our servers.

Onpnt: Thanks for the input i tried server.execute first.. then thought.. what the hey.. why don't i just use response.redirect? and so i did and it worked!! hehe.

This is what happens:
welcome.asp gets info then passes it onto send.asp.. send.asp takes the info and puts it all into a mailto line.. so what i have in send.asp is:

Response.redirect(&quot;mailto:&quot; & toEmail & &quot;body=&quot; & mybody & &quot;subject=&quot; & subject)

Thanks for ur help.

T
 
O wait.. this isn't wat i expected.. I don't like how IE gets redirected too with the weird mailto:blahblah in the address bar.. is there a way to do it so that the client pops up but IE stays @ the same page? (can't use redirect anymore here rite?)

Thanks

T
 
you can just change to request.form and it will take the values out of the url Not everything you type is understanding to others! Think about that before getting upset with a wrong answer to your question.

admin@onpntwebdesigns.com
 
I replaced:

Response.Redirect(mailCommand)

with

Response.Form(mailCommand)

and now I'm getting this error msg:

Error Type:
Microsoft VBScript runtime (0x800A01B6)
Object doesn't support this property or method: 'Form'
/media/send.asp, line 19

mailCommand = &quot;mailto:blah.com&quot;

What's wrong? i get this error msg also if i use Request.Execute

Thanks.

T
 
no, no
all of your request.querystring's with request.form

Hope that helps
admin@onpntwebdesigns.com
 
you'll also need to change from the GET to the POST method in your form Hope that helps
admin@onpntwebdesigns.com
 
Ohh.. nono.. sorry.. what i meant was i don't want IE to be directed to the mailto page. Like i want it to call upon the mailto command but stay @ send.asp page. I want the page to stay @ send.asp with the email client popping up.

Thanks.

T
 
U know how it is when u just put:
<a href=&quot;mailto:blah@blah.com&quot;>mail me</A>

if i click on that link the client's email client comes up but you don't get redirected to that page..

Thanks.

T
 
You could just put an onload command in the body tag to direct the window location to your new mailto link:
Inside send.asp
Code:
<%
'All of your code for making the mailto
%>
<body onLoad=&quot;document.src='<%=mailtoAspString%>';&quot;>
The obvious problem here is going to be quotes though, but what happens is you process all of the form info and then build your mailto address and link. Then put that in the body tag so that when the page loads on the clients machine it changes/redirects to the mailto link, which should pop open the email client without creating a new window.
-Tarwn ------------ My Little Dictionary ---------
Reverse Engineering - The expensive solution to not paying for proper documentation
 
Thanks Tarwn.. but it doesn't seem like it's doing anything.

Here's the code:

<HTML>
<HEAD>
</HEAD>

<body onLoad=&quot;document.src='<%=mailtoAspString%>';&quot;>

<%
Dim strFileName
Dim strClientName
Dim strToEmail
Dim Subject
Dim MyBody
strFileName = Request.QueryString(&quot;File&quot;)
strToEmail = Request.QueryString(&quot;To&quot;)
strClientName = Request.QueryString(&quot;Client&quot;)
'Subject = strClientName & &quot; has a media file called &quot; & strFileName & &quot; for you.&quot;
MyBody = &quot; & strClientName & &quot;&amp;file=&quot; & strFileName
Response.Write(MyBody)
Dim mailCommand
mailCommand = &quot;mailto:&quot; & strToEmail & &quot;?body=&quot; & MyBody
%>

<FORM METHOD=GET ACTION=&quot;welcome.asp&quot;>
<INPUT TYPE=Submit VALUE=&quot;Return to mail page&quot;>
</FORM>
</BODY>
</HTML>

T
 
Ok, In this case move the body tag to under:
Code:
Dim mailCommand
mailCommand = &quot;mailto:&quot; & strToEmail & &quot;?body=&quot; & MyBody
%>

and then use the variable mailCommand where I have mailtoAspString.

Code:
<HTML>
<HEAD>
</HEAD>

<%
Dim strFileName
Dim strClientName
Dim strToEmail
Dim Subject
Dim MyBody
strFileName = Request.QueryString(&quot;File&quot;)
strToEmail = Request.QueryString(&quot;To&quot;)
strClientName = Request.QueryString(&quot;Client&quot;)
'Subject = strClientName & &quot; has a media file called &quot; & strFileName & &quot; for you.&quot;
MyBody = &quot;[URL unfurl="true"]http://204.101.162.56/welcome.asp?client=&quot;;[/URL] & strClientName & &quot;&file=&quot; & strFileName
Response.Write(MyBody)
Dim mailCommand
mailCommand = &quot;mailto:&quot; & strToEmail & &quot;?body=&quot; & MyBody
%>
<body onLoad=&quot;document.src='<%=mailCommand%>';&quot;>


<FORM METHOD=GET ACTION=&quot;welcome.asp&quot;>
<INPUT TYPE=Submit VALUE=&quot;Return to mail page&quot;>
</FORM>
</BODY>
</HTML>

Basically what you are doing is telling the client that when the completely load the page, load the mailto link.
Remember, quotes may be a problem here.

If someone would double check the document.src, I always get src and location mixed up.
-Tarwn ------------ My Little Dictionary ---------
Reverse Engineering - The expensive solution to not paying for proper documentation
 
Ok.. here's what i pasted in made some changes to minor syntax mistakes:

<HTML>
<HEAD>
</HEAD>

<%
Dim strFileName
Dim strClientName
Dim strToEmail
Dim Subject
Dim MyBody
strFileName = Request.QueryString(&quot;File&quot;)
strToEmail = Request.QueryString(&quot;To&quot;)
strClientName = Request.QueryString(&quot;Client&quot;)
Subject = strClientName & &quot; has a media file called &quot; & strFileName & &quot; for you.&quot;
MyBody = &quot; & strClientName & &quot;%26file=&quot; & strFileName
Response.Write(MyBody)
Dim mailCommand
mailCommand = &quot;mailto:&quot; & strToEmail & &quot;?body=&quot; & MyBody
%>
<body onLoad=&quot;document.src='<%=mailCommand%>';&quot;>


<FORM METHOD=GET ACTION=&quot;welcome.asp&quot;>
<INPUT TYPE=Submit VALUE=&quot;Return to mail page&quot;>
</FORM>
</BODY>
</HTML>

But nothing's happening.. i can see the Response.Write(MyBody) and the form button.. but outlook doesn't fireup.

T
 
How about just using client-side script within welcome.asp instead?

Here's your 'Send' button and an invisible <a> tag:
Code:
<INPUT type=button value=&quot;Send&quot; onclick=&quot;doEmail();&quot;>
<A name=&quot;maillink&quot; href=&quot;#&quot;>

Here's your script:
Code:
<script language=JavaScript>
function doEmail(){
	var frm=document.frmEmail;
	var mlink=document.anchors.item(&quot;maillink&quot;);
	mlink.href=&quot;mailto:&quot;+frm.txtTo.value+&quot;?body=&quot;+frm.txtMsg.value;
	mlink.click();
}
</script>
To err is human, but to really foul things up requires a computer.
- Farmers' Almanac, 1978

 
Oops, the <a> tag needs to be closed.

Code:
<A name=&quot;maillink&quot; href=&quot;#&quot;></A>

Hope this helps.
To err is human, but to really foul things up requires a computer.
- Farmers' Almanac, 1978

 
Ok Ok Ok.. why not just do this.. Sometimes Javascript is the way to go... check this out:

at the bottom of the send.asp page.. type this:

<script language=&quot;javascript&quot;>
self.location.href = &quot;<%&quot;mailto:&quot; & toEmail & &quot;body=&quot; & mybody & &quot;subject=&quot; & subject%>&quot;
</script>

That should take care of your URL problem.

Cheers,

Gorkem.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top