We help IT Professionals succeed at work.

send email

huda
huda asked
on
Iam trying to send an email I generate a asp code for that however everytime i click on Send button an error message appear that send is Failure.

Please could you help solving this problem

Here is the my code:
<%@ Language=VBScript %>
<HTML>
<HEAD><TITLE>send.asp</TITLE></HEAD>

<BODY BGCOLOR = RosyBrown>
<FONT COLOR =maroon FACE=garamond SIZE= 3><B>You can Send your message here.....</B></FONT>
<P>

<!-- Declear table inside a form for less spaces and more activate -->
<FORM ACTION="send.asp" METHOD="post">
<TABLE>

<!-- Start asp code-->
<%

' Inizelise the variables that will store user's email values------------------
      If Request.Form <> "" Then
            Sender = Trim ( Request.Form ("from") )
            Receiver = Trim ( Request.Form("to") )
            Subject = Trim ( Request.Form("subject") )
            Body = Trim ( Request.Form("body") )
            'validAt = Instr(1,Sender,"@")
            'validAtt = Instr(1,Receiver,"@")
            
' Validation for Sender Field-------------------------------------------
      If Sender = "" Then
                  sendMsg = "<FONT COLOR = NavajoWhite SIZE=2>From Field must not be blank</FONT><BR>"
      ELSE            ' Search for any non-allowed characters
            
                  Allowed = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789._@"
                  For I = 1 to Len(Sender)
                         If Instr (Allowed, Mid(Sender,I,1) ) = 0 Then   'not found, therefore illegal
                              sendMsg = "<FONT COLOR =NavajoWhite>" & "Sender must not contain " & Mid(Sender,I,1) & "</FONT><BR>"
                         ElseIf ( validAt = 1 Or validAt = len(Sender) ) Then
                              sendMsg = "<FONT COLOR =NavajoWhite>Make sure you enter at lease one character before and after @ character</FONT><BR>"
                  Exit For  'no point in continuing -- stop loop at first error found
                       End If
                  Next
                  
                  If len(Sender) < 5 Then
                        sendMsg = "<FONT COLOR =NavajoWhite>please you have to complete the email address<BR>"
                  ElseIf Instr(Sender,"@") = 0 Then
                        sendMsg = "<FONT COLOR =NavajoWhite>you have to enter at least one @</FONT><BR>"
                  Else
                        count = 0
                        For I = 1 to Len(Sender)
                              If Mid(Sender,I,1) = "@" Then
                                    count = count + 1
                              End IF
                         Next
                        
                         If count > 1 Then
                              sendMsg = "<FONT COLOR =NavajoWhite>you have to enter only one @</FONT><BR>"
                         End If
                  End If
                  
                  'If (CInt(validAt+1) = "" Or CInt(validAt-1)="" ) Then
                  '      sendMsg = "<FONT COLOR =NavajoWhite> you have to void spaces before and after @ character</FONT><BR>"
                  'End If            
      End If
          
          
' Validation for Receiver Field-------------------------------------------
            If Receiver = "" Then
                  receiveMsg = "<FONT COLOR = NavajoWhite>To Field must not be blank</FONT><BR>"
            Else
                  Allowed = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789._@"
                  For I = 1 to Len(Receiver)
                         If Instr (Allowed, Mid(Receiver,I,1) ) = 0 Then   'not found, therefore illegal
                              receiveMsg = "<FONT COLOR =NavajoWhite>" & "Sender must not contain " & Mid(Sender,I,1) & "</FONT><BR>"
                         ElseIf ( validAt = 1 Or validAt = len(Receiver) ) Then
                              receiveMsg = "<FONT COLOR =NavajoWhite>Make sure you enter at lease one character before and after @ character</FONT><BR>"
                  Exit For  'no point in continuing -- stop loop at first error found
                       End If
                  Next
                  
                  If len(Receiver) < 5 Then
                        receiveMsg = "<FONT COLOR =NavajoWhite>please you have to complete the email address<BR>"
                  ElseIf Instr(Receiver,"@") = 0 Then
                        receiveMsg = "<FONT COLOR =NavajoWhite>you have to enter at least one @</FONT><BR>"
                  Else
                        count = 0
                        For I = 1 to Len(Receiver)
                              If Mid(Receiver,I,1) = "@" Then
                                    count = count + 1
                              End IF
                         Next
                        
                         If count > 1 Then
                              receiveMsg = "<FONT COLOR =NavajoWhite>you have to enter only one @</FONT><BR>"
                         End If
                  End If      
                  
                  'If (CInt(validAtt+1) = "" Or CInt(validAtt-1)="" ) Then
                  '      receiveMsg = "<FONT COLOR =NavajoWhite> you have to void spaces before and after @ character</FONT><BR>"
                  'End If            
      
      End If
            
            
' Validation for Subject Field-------------------------------------------
            If Subject = "" Then
                  subjectMsg = "<FONT COLOR = NavajoWhite>Subject Field must not be blank</FONT><BR>"
            Else
                  For I = 1 to Len(Subject)
                        If i > 30 Then
                              subjectMsg = "<FONT COLOR=NavajoWhite>Subject must not contain more than 30 characters</FONT><BR>"
                  Exit For
                        End If
                  Next
            End If
            
            
' Validation for Body Field-------------------------------------------
            If Body <> "" Then
                  For I = 1 to Len(Body)
                        If i > 225 Then
                              bodyMsg = "<FONT COLOR=NavajoWhite>The area of your message will include no more than 225 characters</FONT><BR>"
                  Exit For
                        End If
                  Next
            End If
            
            
'General Validation Message-----------------------------
            
      If sendMsg <> "" Or receiveMsg <> "" Or subjectMsg <> "" Or bodyMsg <> "" Then
            GeneralMsg = "<FONT COLOR=NavajoWhite FACE=Garamond SIZE=3><B>Please correct the errors noted below:<BR.<BR></B></FONT>"
            Response.Write("<P>")
      Else
            GeneralMsg = "<FONT COLOR=blue FACE=Garamond SIZE=3><B>All data is verified.</B></FONT><BR>"
            ' Set Input variables to Session Object so that they can be used in another page------------
            Session("from") = Sender
            Session("to")=Receiver
            Session("subject") = Subject
            Session("body") =Body
            ' This is a response method that will send a client to a different web or asp page----------
            'Response.Redirect("<a href=receive.asp></a>")
      End If
End If


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

objCDONTS.From = Sender
objCDONTS.To = Receiver
objCDONTS.Subject = Subject
objCDONTS.Body = Body
objCDONTS.Send
Set objCDONTS = Nothing

Response.Write("Message was successfully sent to" & Receiver)
                  
%>

<%=GeneralMsg%>

<!--End of asp code-->

<!--Start HTML code-->
      <TR>
            <TD><FONT COLOR=maroon FACE=Garamond>From:</FONT></TD>
            <TD><%=sendMsg%><INPUT TYPE=text name=from value="<%=Sender%>"></TD>
      </TR>
      
      <TR>
            <TD><FONT COLOR=maroon FACE=Garamond>To:</FONT></TD>
            <TD><%=receiveMsg%><INPUT TYPE=text name=to value="<%=Receiver%>"></TD>
      </TR>
      
      <TR>
            <TD><FONT COLOR=maroon FACE=Garamond>Subject:</FONT></TD>
            <TD><%=subjectMsg%><INPUT TYPE=text name=subject value="<%=Subject%>"></TD>
      </TR>
      
      <TR>
            <TD><FONT COLOR=maroon FACE=Garamond>Body:</FONT></TD>
            <TD><%=bodyMsg%><TEXTAREA NAME=body><%=Body%></TEXTAREA></TD>
      </TR>
      
      <TR>
      <P>
            <TD COLSPAN=2><CENTER><INPUT TYPE=submit value="Send"> <INPUT TYPE=reset VALUE="Reset"></CENTER></TD>
      </TR>
      
 </TABLE>
</FORM>
<!-- End of HTML code-->
</BODY>
</HTML>
 
Comment
Watch Question

Commented:
what is the error message shown?

Author

Commented:
This is the message:

Server object error 'ASP 0177 : 800401f3'
Server.CreateObject Failed

/send.asp, line 155

800401f3

Commented:
sounds like you need to install smtp services.  that is where the cdonts object is installed from.

CDO works by using the SMTP service in IIS, unless Exchange is installed, then it will just use

Exchange's
SMTP system. Before continuing, make sure you have your SMTP service properly set up. You can check
by using the Microsoft Management Consol (MMC), or you can look to see if CDONTS.DLL is in your system32
directory.

Author

Commented:
I looked at folder Microsoft Management Consol (MMC) or Internet Service Manager

however i found it empty......note that i am using Windows98 not Windows2000 or NT

another thing is that I found folder Exchange but it contain only 2 files. They are:

- mailbox.pab
- mailbox.pst

I don't know what to do with these two files.......

Provide me please with extra information that will help me istall one of ISS backages
They are many in the Net....

Commented:
you cannot use cdonts for windows98.
you will need to use another third party component to do this.

Ill post a list of them in the morning(I'm at a different computer).

Rounded IT Consultant / Projects manager / Cloud Consultant / IT Planning
CERTIFIED EXPERT
Commented:
CDONTs and CDO needs SMTP to be installed on the machine.. as said.. use one of these:

How do I send e-mail from ASP?

There are several components that enable you to do this.  
    Genusa's AspMail
    http://www.serverobjects.com/products.htm#Aspmail 
 
    ASPEmail
    http://www.aspemail.com/ 
 
    Dundas Mailer
    http://www.dundas.com/index.asp?/products/mailer 
 
    MailListBot
    http://www.MailListBot.com/ 
 
    EasyMail
    http://www.easymailobjects.com/emobjects/smtp.asp 
 
    w3 Jmail
    http://www.dimac.net/ 
 
    HTMLMailer / HTMLMailerPlus
    http://www.oopadelic.com/htmlmailer/ 
    http://www.oopadelic.com/htmlmailerplus/ 
 
    DevMailer
    http://www.geocel.com/devmailer/ 
 
    VSEmail
    http://www.vsoft-tech.com.au/vsemail/readme.html 
 
    Mabry Mail
    http://www.mabry.com/mail/index.htm 
 
    NNTPClient+SMTPClient
    http://www.liquidcool.com/asp 
 
    SimpleMail
    http://www.adiscon.com/SimpleMail 
 
    AB Active X Mailer
    http://www.geocities.com/ResearchTriangle/2656/abmailer.html 
 
    OCXMail
    http://www.flicks.com/aspmail/ 
 
    WindMail
    http://www.geocel.com/windmail/ 
 
    Zaks.POP3
    http://www.zaks.demon.co.uk/code/cpts/pop/index.html 


ASPEmail is a free one and good.. I recommend you try it first

Explore More ContentExplore courses, solutions, and other research materials related to this topic.