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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Retrieve form info via email 1

Status
Not open for further replies.

piratefan

Programmer
Joined
Jul 20, 2003
Messages
195
Location
US
Does anyone have a link to an example of a simple form submittal that sends the data to an email address? I can't seem to find anything with searches or the texts I have.
Thanks.
 
I am having a problem still. It is sending emails with no data. I am using :
objMail.Body = Request.Form("MainForm")
where MainForm is the id of my form. Trying to get the entire form sent. Any ideas here appreciated.
Thanks.
 
I am trying to use CDONTS to accomplish this. I want to be able to send the entire form without doing any kind of looping if possible.

The following code was given to me by my host :
Code:
<%
Set myMail = CreateObject(&quot;CDONTS.NewMail&quot;) 
myMail.From = &quot;test@test.com&quot; 
myMail.To = &quot;test@test.com&quot; 
myMail.Subject = &quot;Test Subject&quot;
myMail.BodyFormat = 0 
myMail.MailFormat = 0 
myMail.Body = HTML 
myMail.Send 
%>
First of all, I don't know if that will(if working), deliver the entire form. I get a runtime error using the Set... says it is no longer supported. Also, HTML is coming up not declared. And I see no Set myMail = Nothing which I assume would be rejected since Set is not supported.
Any ideas much appreciated. I am redesigning a site for a friend. His original site, the programmer used php and somehow didn't have to do any loops to capture the entire form. I'm lucky I can get by with asp.net.
Thanks.
 
Code:
Sub Button1_Click(sender as Object, e as System.EventArgs)
		Dim objMail As New MailMessage()
		objMail.From = &quot;info@mydomain.com&quot;
		objMail.To = &quot;info@domain.com&quot;
		objMail.Subject = &quot;Life Insurance Quote&quot;
		objMail.Body = RequestForm(?????)
		objMail.BodyFormat = MailFormat.HTML
		SmtpMail.SmtpServer = &quot;mail.wisetracking.com&quot;
		SmtpMail.Send(objMail)
	
End Sub
I am close using the System.Web.Mail. If for example I put objMail.Body=&quot;Name&quot;, I will get the name entry in my form. (&quot;Name&quot; is id for that text box). But I can't figure out how to get the entire form. I have tried using the http.etc address for that page. Would like to be able to get the entire form the most efficient way.
Thanks for all the help Brian.
 
You can do this, but it's not pretty. You might want to just get the Enumerator of the Form object and get each key this way.

objMail.Body = Request.Form.ToString


regards,
Brian
 
Thanks I think I got it. Knock on wood. My head suffices.
 
Request.Form it's obsolete ... was used in normal ASP. In ASP.NET you should use asp controls.
Code:
In your HTML code:
<asp:textbox id=txtMessage runat=server>
<asp:button id=btnSend runat=server text=&quot;Send&quot; onClick=&quot;btnSend_Click&quot;>
Within your script tags:
sub btnSend_Click(sender as Object, e as Eventargs)
dim objMail as MailMessage = new MailMessage
        objMail.From = &quot;info@mydomain.com&quot;
        objMail.To = &quot;info@domain.com&quot;
        objMail.Subject = &quot;Life Insurance Quote&quot;
        objMail.Body = txtMessage.Text
        objMail.BodyFormat = MailFormat.HTML
        SmtpMail.SmtpServer = &quot;mail.wisetracking.com&quot;
        SmtpMail.Send(objMail)
end sub

If you use Framework 1.1, you could use authorised login:
Code:
objMail.Fields(&quot;[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpauthenticate&quot;)[/URL] = 1
objMail.Fields(&quot;[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/sendusername&quot;)[/URL] = &quot;login_name&quot;
objMail.Fields(&quot;[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/sendpassword&quot;)[/URL] = &quot;login_password&quot;

login_name and login_password corresponds to your smtp server authentication.
 
I ended up getting it. Thanks much.
msgStr+ = &quot;Name: &quot; & Name.text & vbcrlf, etc. did it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top