I Can't Get Email to Send!

Discussion in 'Classic ASP' started by Huge Headboards, Aug 21, 2006.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. Hi All,

    Please excuse my terrible uselessness at ASP. I have no idea what i'm doing. I've just looked at the ASP school thing to try and make a mailing list form but it simply doesn't work! Can someone please point me in the right direction, or better still, point me at a page which someone wouldn't mind me lifting???

    Hre's what I have....

    <html>


    <%
    Set myMail=CreateObject("CDO.Message")
    myMail.Subject="Sending email with CDO"
    myMail.From="[email protected]"
    myMail.To="[email protected]"
    myMail.TextBody="This is a message."
    myMail.Send
    set myMail=nothing
    %>


    </body>
    </html>




    Thanks for your help!!!

    Huge.
     
  2. Not sure how this will come out in a forum post but here's a workign example, just change the obvious parts.


    Code:
    
    
    <%
    strHost = "localhost"
    If Request("Send") <> "" Then
    Set Mail = Server.CreateObject("Persits.MailSender")
    Mail.Host = strHost
    Mail.From = Request("From") ' From address
    Mail.FromName = Request("FromName") ' optional
    Mail.AddAddress [email="[email protected]"]youremailaddress[url="mailto:your@mail."]@mail.[/email]net[/url], "you" 'Request("To")
    ' message subject
    Mail.Subject = Request("Subject")
    ' message body
    Mail.Body = Request("Body")
    strErr = ""
    bSuccess = False
    On Error Resume Next ' catch errors
    Mail.Send' send message
    If Err <> 0 Then ' error occurred
    strErr = Err.Description
    else
    bSuccess = True
    End If
    End If
    %>
    <script language="JavaScript" type="text/JavaScript">
    <!--
    function MM_findObj(n, d) { //v4.01
     var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&amp;&amp;parent.frames.length) {
     d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
     if(!(x=d[n])&amp;&amp;d.all) x=d.all[n]; for (i=0;!x&amp;&amp;i<d.forms.length;i++) x=d.forms[i][n];
     for(i=0;!x&amp;&amp;d.layers&amp;&amp;i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
     if(!x &amp;&amp; d.getElementById) x=d.getElementById(n); return x;
    }
    
    
    function MM_validateForm() { //v4.0
     var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
     for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
     if (val) { nm=val.name; if ((val=val.value)!="") {
     if (test.indexOf('isEmail')!=-1) { p=val.indexOf([email="'@'"]'@'[/email]);
     if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
     } else if (test!='R') { num = parseFloat(val);
     if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
     if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
     min=test.substring(8,p); max=test.substring(p+1);
     if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
     } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
     } if (errors) alert('The following error(s) occurred:\n'+errors);
     document.MM_returnValue = (errors == '');
    }
    //-->
    </script>
    <center><font color="#FF9900">[b]Contact me</b></font></center>
    <hr width="98%" color="#A8CBEE" />[b]
    <% If strErr <> "" Then %>
    <center><h3><span>Error occurred: <I><% = strErr %></I></span></h3></center>
    <% End If %>
    <% If bSuccess Then
    %>
    <center><h3><span>Success! Message sent.</span></h3>
    </center>
    <%
    Response.End()
    End If
    %>
    <form action="/thisfile.asp" method="POST" onSubmit="MM_validateForm('From','','RisEmail','FromName','','R','Subject','','R','Body','','R');return document.MM_returnValue">
    <table width="500" cellpadding="4" cellspacing="4" align="center">
    <tr>
    <td><font color="#FF9900">E-Mail:</font></TD>
    <td><font color="#FF9900"><input type="TEXT" name="From" size="30"></font></td>
    </tr>
    <tr>
    <td><font color="#FF9900">Name:</font></TD>
    <td><font color="#FF9900"><input type="TEXT" name="FromName" size="30"></font></td>
    </tr>
    <tr>
    <td><font color="#FF9900">Subject:</font></td>
    <td><font color="#FF9900"><input name="Subject" type="text" size="50"></font></td>
    </tr>
    <tr>
    <td><font color="#FF9900">Message:</font></td>
    <td><font color="#FF9900"><textarea NAME="Body" cols="50" rows="10"></textarea></font></td>
    </tr>
    <tr>
    <td>&amp;nbsp;</td>
    </tr>
    <tr align="center">
    <td>&amp;nbsp;</td>
    <td COLSPAN=2><input type="SUBMIT" name="Send" value="Send E-Mail"></td>
    </tr>
    </table>
    </form>
    
     
  3. Thanks Very Much!!!!
     
  4. If you arewith DASP we do have ASPEmail support,else you will have to download a registered copy of the same in order to use Persits.MailSender Component else you always have an option of using the free emailing CDO component.

    Vikram

    DiscountASP.NET
    www.DiscountASP.NET
     
  5. Vikram,


    The request was for Classic ASP, the Persits ASPEmail component is already available to ASP pages.
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page