Link to home
Start Free TrialLog in
Avatar of dwaarchitects
dwaarchitects

asked on

CDOSYS not sending email - code correct?!?!?

I have setup a form which I want sending using CDOSYS. It all appears to be working fine and the confirmation page shows no errors - however no email is sent and I do not know why! The code appears to be all correct!

This is the code:

[code]

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>

<%
'First lets Dim all the variables we need - this is a comment
Dim MyName
Dim MyAddress
Dim MyPostcode
Dim MyTelephone
Dim MyEmail
Dim MyMessage

'Now lets get some values for the variables from the form
MyName = Request.Form("Name")
MyAddress = Request.Form("Address")
MyPostcode = Request.Form("Postcode")
MyTelephone = Request.Form("Telephone")
MyEmail = Request.Form("Email")
MyMessage = Request.Form("Message")

'Now lets build the body of the email from the data in the form
MyBody = "Name: "& MyName & vbcrlf
MyBody = MyBody & "Address: "& MyAddress & vbcrlf
MyBody = MyBody & "Postcode: "& MyPostcode & vbcrlf
MyBody = MyBody & "Telephone: "& MyTelephone & vbcrlf & vbcrlf
MyBody = MyBody & "Email: "& MyEmail & vbcrlf
MyBody = MyBody & "Message: "& MyMessage & vbcrlf

'Now lets put the variables and other information we need into the mailing script
Set MyMail = CreateObject("CDO.Message")
MyMail.From = "fama@fama.co.uk"
MyMail.To = "paul.worsnop@tesco.net"
MyMail.Subject = "Website Enquiry from Fama.co.uk"
MyMail.TextBody = MyBody
MyMail.Send
Set MyMail= nothing
Response.Write("Your e-mail has been sent")
%>

[/code]
Avatar of Rimvis
Rimvis
Flag of Lithuania image

Do you have Simple Mail Transport Protocol (SMTP) service installed on your WEB server? Is it running?
Avatar of dwaarchitects
dwaarchitects

ASKER

It is stored externally on the web hosts servers i dont do it from a web server that I administer myself.
a) Maybe you can ask web server administrator to check it?
b) You can send e-mail using specific SMTP server: http://msdn2.microsoft.com/en-us/library/ms527274.aspx
Have emailed them asking if can check things out at their end.
One other thing I would like to have setup but am unsure as to how to is I would like the user who fills the form in to recieve a confirmation email stating we have recieved their enquiry - is it a simple addition to the current code to do this?!?!
ASKER CERTIFIED SOLUTION
Avatar of Rimvis
Rimvis
Flag of Lithuania image

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
<%
'Send first email

'Now lets get some values for the variables from the form
MyName = Request.Form("Name")
MyAddress = Request.Form("Address")
MyPostcode = Request.Form("Postcode")
MyTelephone = Request.Form("Telephone")
MyEmail = Request.Form("Email")
MyMessage = Request.Form("Message")

'Now lets build the body of the email from the data in the form
MyBody = "Name: "& MyName & vbcrlf
MyBody = MyBody & "Address: "& MyAddress & vbcrlf
MyBody = MyBody & "Postcode: "& MyPostcode & vbcrlf
MyBody = MyBody & "Telephone: "& MyTelephone & vbcrlf & vbcrlf
MyBody = MyBody & "Email: "& MyEmail & vbcrlf
MyBody = MyBody & "Message: "& MyMessage & vbcrlf

'Now lets put the variables and other information we need into the mailing script
Set MyMail = Server.CreateObject("CDO.Message")
Set MyMailConfig = Server.CreateObject("CDO.configuration")
            MyMailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "xxx.xxx.xxx.xxx"
            MyMailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
            MyMailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
            MyMailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
            MyMailConfig.Fields.Update
Set MyMail.Configuration = MyMailConfig

MyMail.From = "fama@fama.co.uk"
MyMail.To = "paul.worsnop@tesco.net"
MyMail.Subject = "Website Enquiry from Fama.co.uk"
MyMail.TextBody = MyBody
MyMail.Send
Set MyMail= nothing
Response.Write("Your e-mail has been sent")

'Repeat above to send confimration...  Change to,subject,textbody
%>