Link to home
Start Free TrialLog in
Avatar of learn
learn

asked on

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 :-))
Avatar of sdland1
sdland1

there are some samples at http://lightning.prohosting.com/~shell123 that should help ya solve this one
Avatar of learn

ASKER

To sdland1:

Thank you. I have just visited the site but just can not find the example I need :-(
if you want it in email search for mail if you would like to make your app an iternet capable app search for winsock
ASKER CERTIFIED SOLUTION
Avatar of stefanx
stefanx

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ameba is an idiot so is mcrider look here http://lightning.prohosting.com/~shell123
Cody - both ameba & mcrider have substantially higher expert scores than you. No need to get insulting.
Avatar of learn

ASKER

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 :-)
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.
Lots of info for 35 points ;) Must be your lucky day.
Avatar of learn

ASKER

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 ;-)
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.