Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    New to the CF scene
    Join Date
    Oct 2003
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    ASP mail problem

    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.
    Last edited by pumpkinpie; 10-27-2003 at 10:10 AM.

  • #2
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    To me it looks like you are using .NET code..........

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

    Eric

  • #3
    Senior Coder Spudhead's Avatar
    Join Date
    Jun 2002
    Location
    London, UK
    Posts
    1,856
    Thanks
    8
    Thanked 110 Times in 109 Posts
    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 ]

  • #4
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    Yeah, it definetly looks like you are trying to running .net code on a asp3 page, which is where the problem is.
    OracleGuy

  • #5
    New to the CF scene
    Join Date
    Oct 2003
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you all for replies.

    Yes it's ASP.net
    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.

    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.
    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

  • #6
    New to the CF scene
    Join Date
    Oct 2003
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #7
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    From the sound of it, they probably disabled the ability to send mail. I'd dump the host and switch to a better one.
    OracleGuy

  • #8
    Senior Coder
    Join Date
    Jun 2002
    Location
    41° 8' 52" N -95° 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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...
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)

  • #9
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.
    Check out the Forum Search. It's the short path to getting great results from this forum.

  • #10
    New to the CF scene
    Join Date
    Oct 2003
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #11
    Senior Coder
    Join Date
    Jun 2002
    Location
    41° 8' 52" N -95° 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Still a slight problem compared to maintaining some of the legacy code I have to deal with at work.

    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.
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)

  • #12
    New to the CF scene
    Join Date
    Oct 2003
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Originally posted by whammy
    Still a slight problem compared to maintaining some of the legacy code I have to deal with at work.

    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.

  • #13
    Senior Coder
    Join Date
    Jun 2002
    Location
    41° 8' 52" N -95° 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    "personal mail"? I think whoever answered your email didn't quite understand what you were talking about.
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)

  • #14
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.
    Check out the Forum Search. It's the short path to getting great results from this forum.

  • #15
    Senior Coder
    Join Date
    Jun 2002
    Location
    41° 8' 52" N -95° 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •