Click to See Complete Forum and Search --> : Sending an e-mail


webdesign
08-03-2004, 10:41 AM
I'm tryingto send the contents of a form to an e-mail address, and I can't get it to work...I was wondering if someone could help me figure this out...my code for the mail is:

Set myMail= Server.CreateObject("CDO.Message")
myMail.Subject = "New Service Application"
myMail.To = "web@web.com"
myMail.From = "mail@mail.com"
myMail.Body = "A new application has been submitted"
myMail.Send

set myMail = nothing

And I'm getting the following error:
Server object error 'ASP 0177 : 800401f3'

Server.CreateObject Failed

/website tests/newServiceApp.asp, line 1281

Invalid class string

Anyone know what I'm doing wrong? I sure don't!
(Sorry if this is a dumb question, but I just started learning asp yesterday!)

schizo
08-03-2004, 11:49 AM
Set myMail= Server.CreateObject("CDO.Message")
Your server probably doesn't support this email object. I'd try contacting your host and see what kind of ASP mailer they are using.

buntine
08-03-2004, 12:08 PM
Schizo is correct. This error means that your Web Host does not have the CDO component installed.

Concact the administrator for alternatives such as ASPEmail, etc.

Regards,
Andrew Buntine.

webdesign
08-03-2004, 12:12 PM
Okay...thanks a bunch!

webdesign
08-03-2004, 12:14 PM
oh but wait, new question...is there any way to send the form by e-mail with asp, without opening a mail client (like you can do with php)? Thats what I would like to do...

schizo
08-03-2004, 01:01 PM
Yeah, your method (once enabled) will allow you to send that message through the server's SMTP, thus no need to open a regular mail client.

As stated above, there are plenty of alternatives that can do this... it just depends on which one is installed on the server.

schizo
08-03-2004, 04:18 PM
Actually I was having a similiar problem today when I was attepting to use the CDONTS object (that didn't exsist). I was able to run the script below to find that they had JMail enabled. You could do the same to see what is installed on your server...


<% @ Language="VBScript" %>
<% Option Explicit %>
<%
Dim theComponents(18)

theComponents(0) = Array("ABMailer.Mailman", "ABMailer v2.2+")
theComponents(1) = Array("Persits.MailSender", "ASPEMail")
theComponents(2) = Array("SMTPsvg.Mailer", "ASPMail")
theComponents(3) = Array("SMTPsvg.Mailer", "ASPQMail")
theComponents(4) = Array("CDONTS.NewMail", "CDONTS (IIS 3/4/5)")
theComponents(5) = Array("CDONTS.NewMail", "Chili!Mail (Chili!Soft ASP)")
theComponents(6) = Array("CDO.Message", "CDOSYS (IIS 5/5.1/6)")
theComponents(7) = Array("dkQmail.Qmail", "dkQMail")
theComponents(8) = Array("Dundas.Mailer", "Dundas Mail (QuickSend)")
theComponents(9) = Array("Dundas.Mailer", "Dundas Mail (SendMail)")
theComponents(10) = Array("Geocel.Mailer", "GeoCel")
theComponents(11) = Array("iismail.iismail.1", "IISMail")
theComponents(12) = Array("Jmail.smtpmail", "JMail")
theComponents(13) = Array("MDUserCom.MDUser", "MDaemon")
theComponents(14) = Array("ASPMail.ASPMailCtrl.1", "OCXMail")
theComponents(15) = Array("ocxQmail.ocxQmailCtrl.1", "OCXQMail")
theComponents(16) = Array("SoftArtisans.SMTPMail", "SA-Smtp Mail")
theComponents(17) = Array("SmtpMail.SmtpMail.1", "SMTP")
theComponents(18) = Array("VSEmail.SMTPSendMail", "VSEmail")

Function IsObjInstalled(strClassString)
On Error Resume Next

'// Initialize default values
IsObjInstalled = False
Err = 0

'// Testing code
Dim xTestObj
Set xTestObj = Server.CreateObject(strClassString)

If 0 = Err Then IsObjInstalled = True

'// Cleanup
Set xTestObj = Nothing
Err = 0

On Error Goto 0
End Function

Response.Write "<html>" & vbNewLine & _
vbNewLine & _
"<head>" & vbNewLine & _
" <title>E-mail Component Test</title>" & vbNewLine & _
"</head>" & vbNewLine & _
vbNewLine & _
"<body bgColor=doublequotewhitedoublequote text=doublequotemidnightbluedoublequote link=doublequotedarkbluedoublequote aLink=doublequotereddoublequote vLink=doublequotereddoublequote>" & vbNewLine & _
"<font face=doublequoteVerdana, Arial, Helveticadoublequote>" & vbNewLine & _
"<table border=doublequote0doublequote cellspacing=doublequote0doublequote cellpadding=doublequote0doublequote align=doublequotecenterdoublequote>" & vbNewLine & _
" <tr valign=doublequotetopdoublequote>" & vbNewLine & _
" <td bgcolor=doublequoteblackdoublequote>" & vbNewLine & _
" <table border=doublequote0doublequote cellspacing=doublequote1doublequote cellpadding=doublequote4doublequote>" & vbNewLine & _
" <tr valign=doublequotetopdoublequote>" & vbNewLine & _
" <td bgcolor=doublequotemidnightbluedoublequote colspan=doublequote2doublequote align=doublequotecenterdoublequote><font size=doublequote2doublequote color=doublequotemintcreamdoublequote><b>E-mail Component Test</b></font></td>" & vbNewLine & _
" </tr>" & vbNewLine

Dim i

For i = 0 To UBound(theComponents)
Response.Write " <tr>" & vbNewLine & _
" <td bgColor=doublequote#9FAFDFdoublequote align=doublequoterightdoublequote><font size=doublequote2doublequote><strong>" & theComponents(i)(1) & ":&nbsp;</strong></font></td>" & vbNewLine & _
" <td bgColor=doublequote#9FAFDFdoublequote align=doublequotecenterdoublequote><font size=doublequote2doublequote>"

If Not IsObjInstalled(theComponents(i)(0)) Then
Response.Write("not installed")
Else
Response.Write("<strong>installed!</strong>")
End If

Response.Write "</font></td>" & vbNewLine & _
" </tr>" & vbNewline
Next


Response.Write " </table>" & vbNewLine & _
" </td>" & vbNewLine & _
" </tr>" & vbNewLine & _
"</table>" & vbNewLine & _
"</font>" & vbNewLine & _
"</body>" & vbNewLine & _
vbNewLine & _
"</html>" & vbNewLine
%>