?
Solved

Help with Form submission using ASP and the CDOSYS object.

Posted on 2004-10-27
9
Medium Priority
?
158 Views
Last Modified: 2010-04-06
Hi, I am having a nightmare.  I have a website and I am trying to submit forms details to my email using ASP with the CDOSYS object.

I have the following code

<%

If request("submit") <> "" THEN
Set objEMail = Server.CreateObject("CDO.Message")
Set objConfig = Server.CreateObject("CDO.Configuration")
Set Confi = objConfig.Fields
Confi("http://schemas.microsoft.com/cdo/configuration/sendusing") = 1
Confi("http://schemas.microsoft.com/cdo/configuration/smtpserverpickupdirectory") = "C:\inetpub\mailroot\pickup"
Confi.Update
Set objEMail.Configuration = objConfig
objEMail.To = "myemail@blah,blah,blah.co.uk"
objEMail.From = Request("from")
objEMail.Subject = Request("subject")
objEMail.TextBody = Request("message")  
objEMail.Send
Set objEMail = Nothing

Response.Write("Message Sent")
Else

%>

<form method="post" action="this.asp">
From Email: <INPUT type=text name="from"><br />
Subject: <INPUT type=text name="subject"><br />
Message: <TEXTAREA name="message" rows=10 cols=40></TEXTAREA><br />
<INPUT type="submit" value="Send" name="submit">
</form>

<%
End If
%>

I get no errors and my page reloads again as requested, but know information is sent to my email address why????

Hope someone can help......bye the way have changed my email address in the code and replaced it with a made up address...hence "myemail@blah,blah,blah.co.uk".

It sending me around the bend...please help.Cheers



0
Comment
Question by:dthomas31uk
  • 3
  • 3
  • 2
  • +1
9 Comments
 
LVL 13

Expert Comment

by:davidlars99
ID: 12425330
what do you mean by this?
> I get no errors and my page reloads again as requested
0
 
LVL 2

Expert Comment

by:MGrassman
ID: 12425426
Is this a server you own or a hosting company.

If its a hosting company make sure
    Confi("http://schemas.microsoft.com/cdo/configuration/smtpserverpickupdirectory") = "C:\inetpub\mailroot\pickup"
is the correct setting.

If it's your machine are you able to send emails through your smpt server any other way.

0
 

Author Comment

by:dthomas31uk
ID: 12425978
The page this.asp is the name of the actual page that the code is in.  I get no errors but no data is sent to the mail address in question
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 2

Expert Comment

by:MGrassman
ID: 12426070
I'm sure you have done this but have you checked your spam mail or anything like that to see if it's getting re-routed.
0
 
LVL 13

Expert Comment

by:nurbek
ID: 12430813
objEMail.From = Request("from")

should be a valid email

0
 

Author Comment

by:dthomas31uk
ID: 12431605
Dear nurbek...have just discovered that...thank you was ...entering anything in the form field while I was testing it...it works fine now.  Thanks

One other question for you how do I send information if I have more than four form fields on my web page because have discovered the objEMail. only has four parameters that allow you to store form data which are objEMail.To, objEMail.From , objEMail.Subject, objEMail.TextBody.  Are there any other objEmail parameters or do you have to write code differently.

Thank you
0
 
LVL 13

Expert Comment

by:nurbek
ID: 12431645
'add to show the from name
 objCDOMail.From = "Sender<sender@sender.com>"

'to send in html format
objCDOMail.MailFormat = 0
objCDOMail.BodyFormat = 0
objCDOMail.Body = "line 1<br> Line 2"

0
 

Author Comment

by:dthomas31uk
ID: 12431686
Dear Nurbek How does that work then...can you explain please..... say I have got 7 forms
one called To,
one called from,
one called subject
one called comments,
one called dateofstart
one called dateoffinish
one called telephone

Cheers
0
 
LVL 13

Accepted Solution

by:
nurbek earned 1500 total points
ID: 12431742
you have to organize it according to your code, make the desired message and then send it
msg = "hi, <br>" & Request("name") ....

here how to send the whole form elements

Dim myMessage  

'to get form elements
 
 For Each Field In Request.Form
          myMessage = myMessage & "<b>" &  Field & "</b>: " & Request.Form(Field) & "<BR>" & vbCrLf
     Next 'Field

Set objEMail = Server.CreateObject("CDO.Message")
Set objConfig = Server.CreateObject("CDO.Configuration")
Set Confi = objConfig.Fields
Confi("http://schemas.microsoft.com/cdo/configuration/sendusing") = 1
Confi("http://schemas.microsoft.com/cdo/configuration/smtpserverpickupdirectory") = "C:\inetpub\mailroot\pickup"
Confi.Update
Set objEMail.Configuration = objConfig
objEMail.To = "myemail@blah,blah,blah.co.uk"
objEMail.From = Request("from")
objEMail.Subject = Request("subject")
objEMail.MailFormat = 0
objEMail.BodyFormat = 0
objEMail.TextBody = myMessage  
objEMail.Send
Set objEMail = Nothing
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

593 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question