• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 187
  • Last Modified:

send a sting from the page?

Hi,

In ActiveX Document EXE Project, how to let the visitor send the text1.text to me?

(If it is too easy, I am sorry :-))
0
learn
Asked:
learn
  • 5
  • 3
  • 2
  • +1
1 Solution
 
sdland1Commented:
there are some samples at http://lightning.prohosting.com/~shell123 that should help ya solve this one
0
 
learnAuthor Commented:
To sdland1:

Thank you. I have just visited the site but just can not find the example I need :-(
0
 
sdland1Commented:
if you want it in email search for mail if you would like to make your app an iternet capable app search for winsock
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
stefanxCommented:
It depends a little bit on what you want to do. I'll assume here that you are asking how to send data to an ASP program on your webserver (you just said "send to me" - is "me" a webserver?)

If this is the case, you need to write a little ASP program that will accept text1.text. The Userdocument object does not contain an intrinsic method for posting information. However, it contains a method for retrieving data. Provided this data is relatively small, you can send it as part of the URL that you are referencing.

For example, let's say that your webserver is located at 192.168.0.1 and that you a virtual directory there called /thing/. You can now write an ASP program called dothing.asp which takes a parameter called text1. You access this URL by accessing
 
http://192.168.0.1/thing/dothing.asp?text1=xxxx

where xxx is whatever the user type in.
To send this from your UserDocument object, say

UserDocument.AsyncRead "http://192.168.0.1/thing/dothing.asp?text1=" & text1.text, vbAsybcTypeByteArray

On the Server side, you will be able to retrieve the value by referring to

Request.QueryString("text1").

Not that parameters that have spaces in (say the user typed "My Name is Joe") need to be fixed so that the spaces either reflect + characters or %20 (% plus the hex code of the character)

Another option is to put an Inet Control on your userdocument and use it to perform an HTTP Post. Or, if you have VB5 like me where the Inet Control's POST just simply doesn't work, you can do it yourself with the Winsock Control.

Hope that helps
0
 
cody76589Commented:
ameba is an idiot so is mcrider look here http://lightning.prohosting.com/~shell123
0
 
stefanxCommented:
Cody - both ameba & mcrider have substantially higher expert scores than you. No need to get insulting.
0
 
learnAuthor Commented:
To stefanx:

Thank you very much.

Sorry, I didn't make my question clear.....that must be very simple:

Put Text1 and Command1 on the userDocument, I want the visitor type something in Text1 and send  Text1.text to my Email address when he click Command1.

It is easy to do in HTML....I never done anything in AxtiveX Document and just want to lean and have fun :-)
0
 
stefanxCommented:
Oh - yeah, that is pretty easy.
In HTML, you would just have a form similar to the following :

<FORM METHOD=POST ACTION="sendmail.asp">
<TEXTAREA NAME="message" ROWS=3 COLS=40>Type your message here</TEXTAREA>
<BR>
<INPUT TYPE=SUBMIT VALUE="Send It">
</FORM>

And you would process this in ASP like

<%
Message = Request.Form("message")
Set MC = Server.CreateObject("SomeMailComponent.Instance")
MC.SendMail (message)
Set MC=Nothing
%>

(Obviously depending on which Mail component your are using etc...).

Now the UserDocument.AsyncRead method does not allow you to post. That is a bit of a pain in the butt, but we can get around it.

Going back to HTML, let's say your form looked as follows :

<FORM METHOD=GET ACTION="sendmail.asp">
<TEXTAREA NAME="message" ROWS=3 COLS=40>Type your message here</TEXTAREA>
<BR>
<INPUT TYPE=SUBMIT VALUE="Send It">
</FORM>

This has the same result as putting a hypelink like http://myserver/sendmail.asp?message=This+is+the+message

And you would process it in your ASP as follows :

<%
Message = Request.QueryString("message")
Set MC = Server.CreateObject("SomeMailComponent.Instance")
MC.SendMail (message)
Set MC=Nothing
%>


You can simulate this in your userdocument, by attaching the following code to your commandbutton :

Sub Command1_Click()

  Dim Tmp As String

  Tmp = Trim$(Text1)
  Tmp = SafeForSQL(Tmp) ' SafeSQL just fixes the string for transmission
  UserDocument.AsyncRead "http://myserver/mail.asp?message=" & Tmp, vbAsyncTypeByteArray

End Sub

Now in this case you don't care to read the response from your ASP page (if you did, just attach code to the Userdocument's AsyncReadComplete event), so you don't care to wait for a response.

Of course, it would be much nicer if you could actually post because what if the user types in a 2MByte comment? Unfortunately you would have to write your own POST routine with either Winsock.cx or msinet.ocx to do this. I have a sample of this if you are interested.

A totally different approach is to let the userdocument make the actual e-mail connection itself. This can be done through a third part SMTP control, or you can write the functionality yourself (use winsock.ocx and look at the RFC for SMTP). The fact that you can do this illustrates the level of functionality that you wield when using an ACtiveX Document. This is particularly useful for applicatons where Server Side HTML just won't do - one example is the printing of decent paper output - HTML just doen't do that well.

In my case, I've used Active-X documents to write an entire VB-Like programming environment - complete with form design, code editor,paper report writer, document handling interface and the option to run server side processes (written in the VB-like code editor!). In addition, because you deploy your ActiveX Document directly on a website, you gain auto-updating of the client side software if you make any changes. The only pain is the signing of you document.

Although not many people use ActiveX documents, they are really very cool and powerful. Pity they only work with IE.
0
 
stefanxCommented:
Lots of info for 35 points ;) Must be your lucky day.
0
 
learnAuthor Commented:
Hi stefanx,

yes, a lucky day :-) but, I still want to know how to do the following job (nothing to do with server) by ActiveX document:

<FORM method=post action="mailto:me@me.com">
Your comments: <INPUT name="visitor">
<INPUT type=submit value="Send">
</FORM>

This should be easier than what you have shown me.. but if it works, you will get more points ;-)
0
 
stefanxCommented:
Sorry - I must have missed your comment on the 31st of Jan. OK, this is also relatively easy, depending on how you want to do it. The easiest by far is to spawn the user's default email client. This of course assumes that the end user actually has an email program and that it is set up correctly.

If however, you want to make sure the message actually gets to you, you probably have to write an elementary mail sender in code. If you want, I can send you a sample of how to talk to an SMTP (Mail) Server direct. Post your email address here and I'll send it to you.
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

  • 5
  • 3
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now