[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Help with Form submission using ASP and the CDOSYS object.

Posted on 2004-10-27
9
Medium Priority
?
156 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I will show you how to create a ASP.NET Captcha control without using any HTTP HANDELRS or what so ever. you can easily plug it into your web pages. For Example a = 2 + 3 (where 2 and 3 are 2 random numbers) Session("Answer") = 5 then we…
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…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Suggested Courses

656 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