ASP Contact form error Server object error 'ASP 0177 : 800401f3' - forms

One of my websites contact/reservations form has suddenly stopped working and I now receive the following error.
Server object error 'ASP 0177 : 800401f3'
Server.CreateObject Failed
/contact2.asp, line 51
I've done a bit of research and it seems to relate to classic ASP commands but
my knowledge of ASP is limited.
Here is the full code:-
<%
name = request.form("name")
email = request.form("email")
phone = request.form("phone")
guests = request.form("guests")
datum2 = request.form("datum2")
info = request.form("info")
time_hour = request.form.item("time_hour")
time_minute = request.form.item("time_minute")
moda_event = request.form.item("modaEvent")
sign_up = request.form.item("signup")
If name="" or email="" Then
url = "reservations.asp?reqd=* indicates required field&name=" & mname & "&email=" & memail
If name="" Then
url = url & "&mname=*"
End if
If email="" Then
url = url & "&memail=*"
End if
response.redirect url & "&foobar=foobar#form"
response.end
End if
Dim objCDONTS ' Email object
Dim strFromName ' From persons' real name
Dim strFromEmail, strToEmail ' Email addresses
Dim strSubject, strName, strPhone, strEmail, strGuests, strDate, strHour, strMinute, strEvent, strInfo, strSignup 'Message
Dim misccompo
strSubject = "Reservation Form"
strFromName = Trim(Request.Form("name"))
strFromEmail = Trim(Request.Form("email"))
strToEmail = "reservations#modarestaurant.co.uk"
strName = Trim(Request.Form("name"))
strPhone = Trim(Request.Form("phone"))
strEmail = Trim(Request.Form("email"))
strGuests = Trim(Request.Form("guests"))
strDate = Trim(Request.Form("datum2"))
strHour = Trim(Request.Form.Item("time_hour"))
strMinute = Trim(Request.Form.Item("time_minute"))
strEvent = Trim(Request.Form.Item("moda_event"))
strInfo = Trim(Request.Form("info"))
strSignup = Trim(Request.Form.Item("signup"))
Set objCDONTS = Server.CreateObject("CDONTS.NewMail")
objCDONTS.From = strFromName & " <" & strFromEmail & ">"
objCDONTS.To = strToEmail
objCDONTS.Subject = strSubject
objCDONTS.Body = "--------------------------------------" & vbcrlf & vbcrlf & "Name: " & strName & vbcrlf & "Contact Number: " & strPhone & vbcrlf & "Email Address: " & strEmail & vbcrlf & "No. of Guests: " & strGuests & vbcrlf & "Date: " & strDate & vbcrlf & "Time: " & strHour & ":" & strMinute & vbcrlf & "Event: " & strEvent & vbcrlf & "Additional Info: " & vbcrlf & strInfo & vbcrlf & "Newsletter Signup: " & strSignup &vbcrlf & "--------------------------------------------------------------" & vbcrlf & "MESSAGE ENDS: End of info"
objCDONTS.Send
Set objCDONTS = Nothing
response.redirect "thank-you.asp"
response.end
%>
The line 51 error is this line;
Set objCDONTS = Server.CreateObject("CDONTS.NewMail")
Any help would be greatly appreciated.

The error
Server object error 'ASP 0177 : 800401f3'
Server.CreateObject Failed
/contact2.asp, line 51
means that the object could not be created because it could not find the appropriate DLL for the object requested. In other words, it is looking for the CDONTS COM component that was included with NT SP4 as the file cdont.dll. CDONTS was deprecated in Windows 2000 and completely removed in Windows 2003. Therefore, if you are using Window 2003, Windows 2008 or Windows 2012 server this error makes sense since the DLL is not present.
To fix this problem try the following - use CDOSYS. CDOSYS (cdosys.dll) is a library file provided as part of IIS for Windows 2000, Windows 2003 Server, and Windows 2008 Server. This DLL enabled applications to route SMTP messages across multiple platforms and added much more functionality over the older CDONTS library.
Here is a greatly simplified example to model some changes on
Dim Message As New CDO.Message
sch = "http://schemas.microsoft.com/cdo/configuration/"
Set cdoConfig = CreateObject("CDO.Configuration")
with cdoConfig.Fields
.item(sch & "sendusing") = 2
.Item(sch & "smtpserver") = "mail.xxxx.com" ' your SMTP mail server
.Item(sch & "smtpserverport") = 2525
.update
end with
'Create CDO message object
Set Message = CreateObject("CDO.Message")
With Message
set .configuration = cdoConfig
'Set email adress, subject And body
.From = strFromName
.To = strToEmail
.Subject = strSubject
.TextBody = TextBody
'Send the message
.Send
End With

Related

Send to mail recipient vbscript not longer working

I used to use below VBscript to send files by mail as attachments to be able to add my signature in the e-mail message.
Since about two weeks the VBscript is showing an error every time I try to send a file. I tried to use normal "send to/mail recipient" and it works fine.
Would you advice how can this be solved?
Code:
Option Explicit
Dim objArgs, OutApp, oNameSpace, oInbox, oEmailItem, olMailItem
Dim a, oAttachments, subjectStr, olFormatHTML
olMailItem = 0
olFormatHTML = 2
Set objArgs = WScript.Arguments 'gets paths of selected files
Set OutApp = CreateObject("Outlook.Application") 'opens Outlook
Set oEmailItem = OutApp.CreateItem(olMailItem) 'opens new email
For a = 0 to objArgs.Count - 1
Set oAttachments = oEmailItem.Attachments.Add(objArgs(a))
subjectStr = subjectStr & Right(objArgs(a),Len(objArgs(a))-(InStrRev(objArgs(a),"\"))) & ", " 'recreates the default Subject e.g. Emailing: file1.doc, file2.xls
Next
If subjectStr = "" then subjectStr = "No Subject "
oEmailItem.Subject = "Emailing: " & Left(subjectStr, (Len(subjectStr)-2))
oEmailItem.BodyFormat = olFormatHTML
oEmailItem.Display
Error message:
Unable to execute - arguments list is too long

Send email with attachment from any email program

I need to send an email from an MS Access database with an attachment (not an Access object, but a separate file), but not tied to any one email software (Groupwise, Outlook, etc). I have found code to send an email with an attachment using Groupwise and Outlook, and there is the generic DoCmd.SendObject which only appears to support attaching Access objects. Is there a way to send an email from Access with an attachment, regardless of the email client configured on the user's PC?
Rationale: There's complications with software rollout here. The machine I work on has Access 2013 and Outlook 2013 installed. The users of the database are running Access 2010, but when I compile the database into a .accde in 2013, it does not work on 2010. The only way I can get it to work is to compile it on a much older PC also running Access 2010. However, this old PC does not have Outlook and IT won't/can't install Outlook on it. This means I can't compile the database using the Outlook library, as there is no Outlook library on the machine.
Here is code I use to send e-mails using Gmail:
Public Function SendEmailViaGmail(SendTo As String, Optional Subject As String = "", Optional TextBody As String = "", Optional ReplyTo As String = "", Optional AttachedFiles As Variant = "") As String
On Error GoTo send_emailErr
Dim ErrNum As Long
Dim ErrDes As String
SendEmailViaGmail = ""
ErrNum = 0
Set cdomsg = CreateObject("CDO.message")
With cdomsg.Configuration.Fields
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 'NTLM method
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
.Item("http://schemas.microsoft.com/cdo/configuration/smptserverport") = 587
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = sendusername '
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = sendpassword
.Update
End With
' build email parts
With cdomsg
.To = SendTo
.FROM = sendusername
.Subject = Subject
.TextBody = TextBody & vbCrLf & vbCrLf & vbCrLf & "--" & vbCrLf & "Sent using Marlan Data-Systems"
If IsArray(AttachedFiles) Then
For Each AttachedFile In AttachedFiles
If Len(AttachedFile) > 3 Then .AddAttachment AttachedFile
Next
Else
If Len(AttachedFiles) > 3 Then .AddAttachment AttachedFiles
End If
.send
End With
SendEmailViaGmail = "Done!"
send_emailExit:
Set cdomsg = Nothing
Exit Function
send_emailErr:
ErrNum = Err.Number
ErrDes = Err.Description
Select Case Err.Number
Case -2147220977 'Likely cause, Incorrectly Formatted Email Address, server rejected the Email Format
SendEmailViaGmail = "Please Format the Email Address Correctly."
Case -2147220980 'Likely cause, No Recipient Provided (No Email Address)
SendEmailViaGmail = "Please Provide an Email Address"
Case -2147220960 'Likely cause, SendUsing Configuration Error
SendEmailViaGmail = "SendUsing Configuration Error"
Case -2147220973 'Likely cause, No Internet Connection
SendEmailViaGmail = "Please Check Internet Connection"
Case -2147220975 'Likely cause, Incorrect Password
SendEmailViaGmail = "Please Check Password"
Case Else 'Report Other Errors
SendEmailViaGmail = ""
End Select
SendEmailViaGmail = SendEmailViaGmail & " Error number: " & Err.Number & " Description: " & Err.Description
'If ErrNum = -2147220975 Then
' cdomsg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smptserverport") = 465
' Resume
'End If
Resume send_emailExit
End Function
AttachedFiles is a String, or an Array of Strings, representing full paths to file or files that are to be attached to the email.
CDO.message is a Microsoft windows object.
You can replace value of smtpserver to some other mailing service. If you do so, please be sure to modify other parameters as well.
Code is based on code I found on the web.

Classic ASP Mail - Error send to user and admin

I am sending a mail using CDO.Message. When the user submits a form, the form details to be sent to the Web Site Owner and a Acknowledgement mail to the user. The later is not working for me. I have repeated the same code twice by changing the configuration names, I simply get "Internal Server Error"
My Code (mail to the Web Site Owner)
<%
name = Request.Form ("name")
email = Request.Form ("email")
phone = Request.Form ("phone")
message = Request.Form ("message")
Dim iMsg, iConf, Flds, vSub
Response.CodePage = 65001
Response.CharSet = "utf-8"
Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")
Set Flds = iConf.Fields
'sending email with Google Apps Premium SMTP server (with autentication)
schema = "http://schemas.microsoft.com/cdo/configuration/"
Flds.Item(schema & "sendusing") = 2
Flds.Item(schema & "smtpauthenticate") = 1
Flds.Item(schema & "smtpserver") = "localhost"
Flds.Item(schema & "smtpserverport") = 25
Flds.Item(schema & "sendusername") = "info#priceakagri.ru"
Flds.Item(schema & "sendpassword") = "******"
Flds.Update
With iMsg
Set .Configuration = iConf
.BodyPart.Charset = "utf-8"
.To = "info#akagri.ru"
.From = "info#priceakagri.ru"
.Subject="Message from Priceakagri.ru contact page"
.HTMLBody="Здравствуйте! <br><br>You have received an Enquiry from <font color='#337AB7'><b>" & Trim(Request("name")) & "</b></font>.<br><br><br><table><tr><td width='30%' colspan='2' bgcolor='#337AB7'>Message Details</td></tr><tr><td>Name</td><td>" & Trim(Request("name")) & "</td></tr><tr><td>Email</td><td>" & Trim(Request("email")) & "</td></tr><tr><td>Phone</td><td>" & Trim(Request("phone")) & "</td></tr><tr><td>Message</td><td>" & Trim(Request("message")) & "</td></tr></table>"
Set .Configuration = iConf
.Send
End With
set iMsg = nothing
set iConf = nothing
set Flds = nothing
%>
The above code works perfectly for me. If I replicate the same and send user a mail on acknowledgement, I get error. I used the users email as .To and From as - info#priceakagri.ru
I have done this in my earlier sites, where I include a .txt file for the later and still is working for me.
Need help.
Regards,
Badri

Error sending email from VBScript

When running the following script I get the errors -2147220975 and Transport code error: 0x80040217
on error resume next
Const schema = "http://schemas.microsoft.com/cdo/configuration/"
Const cdoBasic = 1
Const cdoSendUsingPort = 2
Dim oMsg, oConf
Set oMsg = CreateObject("CDO.Message")
oMsg.From = "tom.watt.vulpes#gmail.com"
oMsg.To = "tom.watt.vulpes#gmail.com"
oMsg.Subject = "Test from VBScript"
oMsg.TextBody = "If you can read this, the script worked!"
objMsg.AddAttachment "C:\BLA_BLA.txt"
Set oConf = oMsg.Configuration
oConf.Fields(schema & "smtpserver") = "smtp.gmail.com"
oConf.Fields(schema & "smtpserverport") = 465
oConf.Fields(schema & "sendusing") = cdoSendUsingPort
oConf.Fields(schema & "smtpauthenticate") = cdoBasic
oConf.Fields(schema & "smtpusessl") = True
oConf.Fields(schema & "sendusername") = "tom.watt.vulpes#gmail.com"
oConf.Fields(schema & "sendpassword") = "PASSWORD"
oConf.Fields.Update()
oMsg.Send()
If Err Then
resultMessage = "ERROR " & Err.Number & ": " & Err.Description
Err.Clear()
Else
resultMessage = "Message sent ok"
End If
Wscript.echo(resultMessage)
I've tried countless scripts from the internet but none of them seem to work. What am I doing wrong?
Thanks, Tom
EDIT: I am running Windows 10
Transport code error: 0x80040217 can be a few different things depending on the situation. The links below should guide you in the right direction...
Overflowing Stack
MSDN
Something that I have found that may help in relation to this was that the domain I was wanting to use this script for had a SPF record with a hard fail attached to it and so then only their specific email server would work with this which in my case was Office 365 but when testing I was using their ISP and attempting to relay unauthenticated through them.
So check SPF also, hope this helps.
Cozzie

How to check is myMail.Send is true/false

<%
Dim sent
Dim YourName
Dim YourEmail
Dim YourMessage
Set myMail2=CreateObject("CDO.Message")
YourName = Trim(Request.Form("Name"))
YourEmail = Trim(Request.Form("Email"))
YourMessage = Trim(Request.Form("Message"))
Dim Body
Dim body2
Body = Body & "Their Name: " & VbCrLf & YourName & VbCrLf & VbCrLf
Body = Body & "Their Email: " & VbCrLf & YourEmail & VbCrLf & VbCrLf
Body = Body & "Their Message: " & VbCrLf & YourMessage & VbCrLf & VbCrLf
Set myMail=CreateObject("CDO.Message")
myMail.Subject="A New Enquiry!"
myMail.From="admin#musicalmatters.co.uk"
myMail.To="james#devine.eu"
myMail.TextBody=Body
myMail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing")=2
'Name or IP of remote SMTP server
myMail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver")="smtp.1and1.com"
'Server port
myMail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport")=25
myMail.Configuration.Fields.Update
myMail.Send
set myMail=nothing
body2="Thank you for contacting us!" & VbCrLf & "This is just a brief message to let you know your form was submitted successfully!"& VbCrLf & VbCrLf & "You may reply to this address, but you may not necessarily receive a reply, "& "you should receive a reply in 1-2 business day(s)!"& VbCrLf & "Thank you very much,"& VbCrLf & VbCrLf & "Musical Matters."& VbCrLf & "admin#musicalmatters.co.uk"
Set myMail2=CreateObject("CDO.Message")
myMail2.Subject="Thanks for Contacting Us!"
myMail2.From="admin#musicalmatters.co.uk"
myMail2.To=YourEmail
myMail2.TextBody=body2
myMail2.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing")=2
'Name or IP of remote SMTP server
myMail2.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver")="smtp.1and1.com"
'Server port
myMail2.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport")=25
myMail2.Configuration.Fields.Update
myMail2.Send
If myMail2.Send="" Then
Response.Redirect("http://www.musicalmatters.co.uk/success.htm")
set myMail2=nothing
Else
Response.Redirect("http://www.musicalmatters.co.uk/error.htm")
set myMail2=nothing
End If
The problem with my asp script is that I need to check whether the emails were sent or not and redirect them to an error or success page depending on the result.
If myMail2.Send="" Then
Response.Redirect("http://www.musicalmatters.co.uk/success.htm")
set myMail2=nothing
Else
Response.Redirect("http://www.musicalmatters.co.uk/error.htm")
set myMail2=nothing
End If
in the code above mymail2.Send="" because i was testing something, i know i have to change the value to true or false, please be hasty with your answers!
Thanks in advance!
If the email address has valid syntax and the SMTP server is up and running, the Send method will never throw error, even if the email address does not exist.
There is no way to know 100% if the email reached its destination - one thing I can think is to check (using FSO) the BadMail and Queue folders in the SMTP root after few seconds from sending, and if they contain new entry it means something went wrong.
However as you're using external mail service, you'll have to contact them and ask for a way to get notified somehow when the delivery fails.
Seems to require using On Error statement.
On Error Resume Next
myMail2.Send
If Err.Number = 0 Then
set myMail2 = Nothing
Response.Redirect("http://www.musicalmatters.co.uk/success.htm")
Else
set myMail2 = Nothing
Response.Redirect("http://www.musicalmatters.co.uk/error.htm")
End If