...

View Full Version : ASP mail problem



pumpkinpie
10-27-2003, 11:08 AM
Hello masters,

I am new to ASP,
I need a script that sends an Email to the visitor and site owner.

Here's the script I found.

<%@ Import Namespace="System.Web.Mail"%>

<%
Dim objMail As New System.Web.Mail.MailMessage()

objMail.From = "address1@hotmail.com"
objMail.To = "address2@hotmail.com"
objMail.Subject = "The Subject Line"
objMail.BodyFormat = MailFormat.Html
objMail.Priority = MailPriority.High
objMail.Body = "********************<BR>" & _
"Thank you for visiting CodeToad.com" & _
"********************<BR>"

System.Web.Mail.SmtpMail.SmtpServer = "mail.domain.com"
System.Web.Mail.SmtpMail.Send(objMail)
objMail = Nothing

%>


And this is the error I get.

Microsoft VBScript compilation error '800a0401'

Expected end of statement

/test/mail.asp, line 4

Dim objMail As New System.Web.Mail.MailMessage()
------------^


I did some searches, but only got more confused, could you please help.

A1ien51
10-27-2003, 02:33 PM
To me it looks like you are using .NET code..........

One....Are you using .NET
Two....does your server support email....

Eric

Spudhead
10-27-2003, 02:35 PM
Unless I'm very much mistaken, that looks like ASP.NET code. Which is not ASP code.

If you're doing this in ASP.NET, then I shall cover my embarrasment with a small cough and hope to shuffle away unnoticed.

If you want to do it in ASP, though, you'll need a mail component like CDONTS - a quick Google (or even a search on this forum) for "ASP CDONTS" should provide you with enough reading material and examples.

Any help?


[Edited to add - SNAP :) ]

oracleguy
10-27-2003, 07:06 PM
Yeah, it definetly looks like you are trying to running .net code on a asp3 page, which is where the problem is.

pumpkinpie
10-28-2003, 12:22 AM
Thank you all for replies.

Yes it's ASP.net :o
The server is covad.net. They didn't reply to my question in more than one week.
Supposedly their server supports ASP and PHP. But the PHP mail() function is disabled. :mad:

I tried CDONTS too, and it was not supported.
Maybe they just don't support sending mails. But then agian they charge $24.99 a month. :confused:
And they refuse to help with scripting. I'm sure yo know what kind of host I'm talking about.

Any suggetions what script to use?

I tried a few different ones. Non worked. I use a simple line of code just to send a mail. If it would help I can post what I tried so far and the error messages.

Thanks again

pumpkinpie
10-28-2003, 12:45 AM
This failed too.

<%@ language= "VBscript" %>
<% Option Explicit

Dim NewMail, Body

Set NewMail = Server.CreateObject("CDONTS.NewMail")

NewMail.To= "client@domain.com"
NewMail.From= "tester@domain.com"
Body= "Hi there, just testing"
NewMail.Subject = "Hello"
NewMail.Body = Body
NewMail.Bodyformat=0
NewMail.Mailformat=0
NewMail.Send

Set NewMail=Nothing
%>

The error:

Server object error 'ASP 0177 : 800401f3'

Server.CreateObject Failed

/test/mail2.asp, line 6

Systemmessage, messageid = 0x800401f3

oracleguy
10-28-2003, 12:50 AM
From the sound of it, they probably disabled the ability to send mail. I'd dump the host and switch to a better one.

whammy
10-28-2003, 03:47 AM
Or you might need to use the default ASP.NET mail scripting, SMTP.Mail() (if I remember the syntax right).

That should be installed with ASP.NET... I have an example for you when I get back to work that works with the default .NET installation...

Roy Sinclair
10-28-2003, 11:08 PM
If this is a .NET page then why isn't it named MAIL.ASPX instead of MAIL.ASP?

The error message you posted shows the name of the page and it's not a .NET page even though the code you posted is. That's why you're getting the ASP vs ASP.NET confusion.

pumpkinpie
10-29-2003, 01:09 AM
Originally posted by Roy Sinclair
If this is a .NET page then why isn't it named MAIL.ASPX instead of MAIL.ASP?

The error message you posted shows the name of the page and it's not a .NET page even though the code you posted is. That's why you're getting the ASP vs ASP.NET confusion.

I tried that, the server returns the entire script as text.
I think I should try a CGI script instead. There's a CGI bin. But I haven't done any perl CGI in more than 3 years, I do PHP the best.
I will talk to the site owner also, to get him to switch the hosts. It is a rip-off to charge $25 a month for hosting and not offering a simple mail function.

whammy
10-29-2003, 02:22 AM
Still a slight problem compared to maintaining some of the legacy code I have to deal with at work. :eek:

I'd just try to get an answer out of the host to see what kind of email they DO support, and work with that.

pumpkinpie
10-29-2003, 04:08 AM
Originally posted by whammy
Still a slight problem compared to maintaining some of the legacy code I have to deal with at work. :eek:

I'd just try to get an answer out of the host to see what kind of email they DO support, and work with that.

Thanks whammy, they support personal mail for another $9. a month, LOL.
I didn't get any replies from the tech support. But I'll keep trying.

whammy
10-29-2003, 04:09 AM
"personal mail"? I think whoever answered your email didn't quite understand what you were talking about. :)

Roy Sinclair
10-29-2003, 09:30 PM
If you name the page mail.aspx and it just returns the code as text it means that the web server doesn't have the .NET framework installed so .NET pages aren't possible with that server. You should be able to get away with an ordinary ASP page though since that appears to be present.

whammy
10-30-2003, 05:43 AM
Good point Roy, what I'd try first is CDONTS again since it's pretty common - you said above that it failed, but this can happen if you don't give it a "real" from address, as well. If you have any email addresses working with that host try those as your from address and then see if the CDONTS code works:

Dim objCDO, txtMessage
txtMessage = "Hi there"
Set objCDO = Server.CreateObject("CDONTS.NewMail")
objCDO.To = strEmail
objCDO.From = "you@yourdomain.com"
objCDO.cc = ""
objCDO.bcc = ""
'objCDO.mailFormat = 0 '1 for text which is default
'objCDO.bodyFormat = 0 '1 for text which is default
objCDO.Subject = "Your subject"
objCDO.Body = txtMessage
objCDO.Send
set objCDO = Nothing

pumpkinpie
10-31-2003, 05:55 AM
Thanks whammy,
I tried your code, with a valid address.
I still get the same error.

Server object error 'ASP 0177 : 800401f3'

Server.CreateObject Failed

/test/mail2.asp, line 6

Systemmessage, messageid = 0x800401f3

I think I should try a CGI script instead.
I'm still waiting for a reply from tech support to find out where the CGI perl path is.

Thanks again :p I mean :D

pumpkinpie
11-01-2003, 10:32 AM
The host doesn't support any mail program, I was informed.
Thank you all for your support. :thumbsup:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum