Solved

ASP Javascript CDOSYS Form to Email Example

Posted on 2004-10-28
4,633 Views
Last Modified: 2008-01-09
I'm in need of a ASP Javascript CDOSYS Form to Email Example. All I've found so far is examples for VBScript and I can't seem to convert it across.
0
Question by:N1nja
    19 Comments
     
    LVL 33

    Expert Comment

    by:sajuks
    CDOSYS works only at the server level . Javascript will be used only to check client side validans.
    Cbscript is used might be only for validn.
    What are you looking for ? Maybe if you post what you've got and explain what you want we might
    be able to help you.
    0
     

    Author Comment

    by:N1nja
    I use JScript/JavaScript as the ASP Programming Language.

    I have multiple forms that previously used CDONTS, but I want to use CDOSYS and need code examples in JavaScript. The only examples I can find are coded in VBScript.
    0
     
    LVL 33

    Expert Comment

    by:sajuks
    the mail that is sent  using  CDOSYS  is ASP language. Javascript doent come in the picture over here.
    Thats why am trying to find out why you need javascript ? is it to validate your form or what ?
    An example or a link would be better  to illustarte your problem

    0
     
    LVL 33

    Expert Comment

    by:sajuks
    Its an example using dreamweaver, but  it might be what you are searching for
    http://www.cgw3.co.uk/tutorials/tutorial.asp?TutorialID=39&CategoryID=3
    0
     

    Author Comment

    by:N1nja
    Do you program ASP? If yes, What Language do you use?


    I USE JAVASCRIPT.


    I use JavaScript for ASP (Active Server Pages) which runs at the server (Server Side).

    I will be using JavaScript for validation (Client Side) when I have completed the Form and CDOSYS Page.
    0
     

    Author Comment

    by:N1nja
    Thanks but that example uses VBScript, not JavaScript.
    0
     
    LVL 33

    Expert Comment

    by:sajuks
    Did you check the code . its a n asp page with javascrip validn done to ensure that no fields are empty.
    If valid the form calls the thankyou.asp page which calls the CDOSYS object.
    What can be simpler than that.
    I hope you dont think that you can call this without asp ?
    0
     

    Author Comment

    by:N1nja
    I refer you to my previous comment:



    Comment from N1nja
    Date: 10/28/2004 11:35AM BST
     Your Comment  


    Do you program ASP? If yes, What Language do you use?


    I USE JAVASCRIPT.


    I use JavaScript for ASP (Active Server Pages) which runs at the server (Server Side).

    I will be using JavaScript for validation (Client Side) when I have completed the Form and CDOSYS Page.
    0
     
    LVL 33

    Expert Comment

    by:sajuks
    Check my profile. I believe it speaks for itself.

    Yes am involved in various web server languages like asp,jsp,php,powerdynamo.
    Client side i prefer javascript.

    What i want to simply state is that  create a simple asp page  save it something like mail.asp
    <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
          <form action="thankyou.asp" method="post" name="fmcontact" id="fmcontact" onsubmit="return yourvalidn()">
            <input name="Name" type="text" id="Name" tabindex="1" onfocus="this.select();" size="50" />
            <input name="Email" type="text" id="Email" tabindex="1" size="50" />
            <textarea name="Details" cols="45" rows="10" id="Details" tabindex="1"></textarea>
            <input type="submit" value="Submit" tabindex="1" />
    </form>
    </body>

    use the thankyou.asp page and se if it works or not.I believe you are getting a bit confused

    0
     
    LVL 33

    Expert Comment

    by:sajuks
    Heres a simple validn script which i presume is soemthing you wanted to be sure i knew what you are talking about
    // mail.asp page
    <% %>
    <head>
    <script>
    function yourvalidn()
    {
    if ( document.fmcontact.Name.value == "" )
    {
    alert ( "Enter Name")
    return false
    }
    if ( document.fmcontact.Email.value == "" )
    {
    alert ( "Enter Email")
    return false
    }
    if ( document.fmcontact.Details.value == "" )
    {
    alert ( "Enter Details")
    return false
    }
    return true
    }
    </script>
    </head>
    <body>
          <form action="thankyou.asp" method="post" name="fmcontact" id="fmcontact" onsubmit="return yourvalidn()">
            <input name="Name" type="text" id="Name" tabindex="1" onfocus="this.select();" size="50" />
            <input name="Email" type="text" id="Email" tabindex="1" size="50" />
            <input name="Details" cols="45" rows="10" id="Details" >
            <input type="submit" value="Submit" tabindex="1" />
          </form></td>
    </body>

    the thankyou.asp page you already have
    0
     

    Author Comment

    by:N1nja
    You might have a great looking profile, but that doesn't mean a thing if you don't understand me.

    This is some of what you have sent me:
    ******************************************************************
    <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
          <form action="thankyou.asp" method="post" name="fmcontact" id="fmcontact" onsubmit="return yourvalidn()">
            <input name="Name" type="text" id="Name" tabindex="1" onfocus="this.select();" size="50" />
            <input name="Email" type="text" id="Email" tabindex="1" size="50" />
            <textarea name="Details" cols="45" rows="10" id="Details" tabindex="1"></textarea>
            <input type="submit" value="Submit" tabindex="1" />
    </form>
    </body>
    ******************************************************************

    May I point out this line:
    <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>

    It tells the server that the programming script used is VBScript not JavaScript as I have stated till I am blue in the face.

    Also validation JavaScript is not an issue, I can write that script myself.


    In my next comment I will give you an example of my JavaScript ASP.
    0
     

    Author Comment

    by:N1nja
    Example Code:

    *****************************************************************
    <%@ Language=JavaScript %>
    <%
    var folderPrefix = "";
    var navTitle = "home";
    var pageTitle = "Home";
    %>
    <!-- #include file="site_content.asp" -->
    <%
    function getLeftNav()
    {
          var sOut = "";
          sOut += openTable("left",leftWidth, "", navTitle);
          sOut += "<tr><td width=\"196\"></td></tr></table>";
          return sOut;
    }
    *****************************************************************

    This is the first section of the default.asp page.
    0
     
    LVL 33

    Accepted Solution

    by:
    Did you check my previous post ? i'd corrcted it in the above post. Did you try to run the code ?
    it was a cut and paste opern error in the case of <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>.

    Still since you feel as am not able to understand you am sorry to 've been wasting your time. Hang on and other experts
    who have a better understanding than me will help you out.

    </UNSUBSCRIBE>

    0
     
    LVL 7

    Assisted Solution

    by:kGenius
    Funny discussion above :-)

    <%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>
    < %

    var iMsg = Server.CreateObject("CDO.Message")
    var iBodyPart = iMsg.BodyPart;
    iBodyPart.ContentTransferEncoding = "8bit";

    var iConf = Server.CreateObject("CDO.Configuration")
    iConf.Fields("cdoSMTPServerName") = "smtp.domain.com"
    iMsg.Configuration = iConf

    var msg = "Message via CDOSYS and Javascript" ;
    iMsg.To = "somebody@domain.com";
    iMsg.From = "me@domain.com";
    iMsg.Subject = "CDO Test jscript";
    iMsg.TextBody = msg;
    iMsg.send()

    %>


    Hope this'll help
    Greetings,
    kGenius
    0
     

    Author Comment

    by:N1nja
    Will check it out in the next hour.

    Did you understand what I was saying in above discussion.
    0
     
    LVL 7

    Expert Comment

    by:kGenius
    The discussion was about the Script Language you can use on a ASP-page?
    You use JScript (or Javascript), sajuks thought you could only use VBscript to make ASP. Wich is not true. VB is the most used Server sided script (javascript the most client-sided script) But they work both fine server-sided. You can even use other languages (third-party lang) in ASP scripts. The third-party languages should be installed then.
    So it was an unusefull discussion. But I found it funny, because you were talking next to each other. Correct me if I thought wrong =)
    Hope the script works. I'm not that good in Javascript server-sided.

    kGenius
    0
     
    LVL 7

    Expert Comment

    by:kGenius
    Hope the script works, I can use the points ;)
    0
     

    Author Comment

    by:N1nja
    It's the best thing I've found yet, can you tell me where you found/learnt this example.

    In reference to the discussion I knew that "sajuks" didn't quite understand me but I understood him, strange on his part because he is a JavaScript Expert apparently.
    0
     

    Author Comment

    by:N1nja
    Sorry to split it but surely he needs some encouragement.
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

     Java Android Coding Bundle

    Whether you're an Apple user or Android addict, learning to code for the Android platform is an extremely valuable, in-demand skill. It all starts with Java, the language behind the apps and games that make Android the top platform it is today.

    When pages do not download correctly, and you don't know why, the first thing you do is to look at the HTML source code of that page, but not all the downloaded files appear always clearly. If your source includes a javascript that computes the name…
    Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php (http://lmgtfy.com?q=how+easy+is+php)  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
    Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
    Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

    911 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now