-1
<%@  language="VBScript" %>

<html>

<head>   

</head>

<body>    

<% 
FromName=request.Form("FromName")

EmailFrom=request.Form("EmailFrom")

EmailTo="sales@trisys.com.my"

'request.Form("EmailTo")

CC=request.Form("CC")

Subject=request.Form("Subject")

Important=request.Form("Important")

Content=request.Form("Content")

myType=request.QueryString("myType")

'CC="trisys@trisys.com.my"

Important="1"

' Declare Variables 

Dim objNewMail, strFilePath 

' Create Instance of NewMail Object 

Set objNewMail = Server.CreateObject("CDO.Message")

' Set Email Priority (1 = Normal) 

objNewMail.Importance = 1 

' Send plain text email 

objNewMail.BodyFormat = 1 

' Senders email address 

objNewMail.From = EmailFrom

' Recipients email address 

objNewMail.To = EmailTo

'objNewMail.CC = CC

' Email Subject 

objNewMail.Subject = Subject

' Email Body 

objNewMail.TextBody = "From:" & FromName & " " & vbcrlf & "Email:" & 
mailFrom & 

vbcrlf & Content

' Send Email 

objNewMail.Send() 

' Destroy object to release it from memory 

Set objNewMail = Nothing 

'response.Write "send to:" & strEmailTo

'response.End

response.Redirect("Result.asp?myType=" & myType & "&AppMsg=<div align=center>

<font color=gray size=2><b><p><p><p>THANK YOU<br>Your enquiry has been sent 
viaemail.<br>We will contact you as soon as possible.</b></font></div>") 
%>

Above is the code from enquiry.asp from my company website which I assume nobody have check it for a long time. and when I try to edit it, the email won't even work. So I am aware this is because of CDONT. So I need someone to help or guide me in changing it to CDOSYS. Hope you guys can help me. this is the error that i get after i click submit at Enquiry page on the website enter image description here

i already try to check the custom error documents button in my plesk.is this what you guys mean?by this message what it trying to say exactly?

enter image description here

nadia
  • 1
  • 1
  • Please learn how to ask a good question. Thanks – Muhammad Qasim Apr 14 '17 at 08:21
  • can you tell me why u feel that way – nadia Apr 14 '17 at 08:29
  • I have updated the tags, this code is classic asp and not asp.net. Also, could you edit your question and post the error message you are getting? – Tasos K. Apr 14 '17 at 08:36
  • thank you for the respond. will edit it as soon as possible – nadia Apr 14 '17 at 08:38
  • @nadia: just FYI, that's a singularly useless error message. You need to [enable detailed error messages](http://stackoverflow.com/questions/2640526/detailed-500-error-message-asp-iis-7-5) on the server, and (if you're using Internet Explorer) make sure your browser doesn't hide the useful information in a misguided attempt at friendliness. – Martha Apr 14 '17 at 14:11

1 Answers1

1

First of all, you need to change your Server.CreateObject statement to create a CDOSYS object rather than a CDONTS object:

Set objNewMail = Server.CreateObject("CDO.Message")

The next difference is the message format. In CDONTS Bodyformat=1 specifies text format, Bodyformat=0 specifies HTML format. CDOSYS does it differently - it has two separate settings instead of Body. Delete your bodyformat line and replace

objNewMail.Body = "From:" & FromName & " " & vbcrlf & "Email:" & EmailFrom & vbcrlf & Content

with

objNewMail.TextBody = "From:" & FromName & " " & vbcrlf & "Email:" & mailFrom & vbcrlf & Content

If you want to send an HTML message you would use objNewMail.HTMLBody. The other settings — To, From, Subject etc. — should all work with CDOSYS.

One big advantage of CDOSYS over CDONTS is that it can use a remote SMTP server—CDONTS can only use a local one. You'll need to add a configuration section if this is the case. You may find that you need to add a configuration section anyway. I'd need to know your SMTP details to know what to put in the config section, but this tutorial covers most of the permutations:

http://www.paulsadowski.com/wsh/cdo.htm

Martha
  • 3,932
  • 3
  • 33
  • 42
John
  • 4,658
  • 2
  • 14
  • 23
  • thank you once again for your help.but i still get same error.can i know what do you men by SMTP details?is it in the code? – nadia Apr 17 '17 at 02:57
  • Have you enabled detailed error messages as @Martha suggested in her comment to your question? If you have then you should get a message which give you a better idea of what's going wrong. By SMTP details I mean details of the SMTP server you're trying to send email through - the ip address, port and (if authenticatation is required) username and password. Whoever runs your webserver should be able to give you this information. – John Apr 17 '17 at 11:43
  • i already check the custom error documents box in my plesk . i already upload the screenshot of the error. is that what you mean by enable detailed error message ?or is it something else? thank youuu – nadia Apr 18 '17 at 07:22