VBScript MsgBox: Trying to bypass permision denied error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • geter
    New Member
    • Oct 2008
    • 1

    VBScript MsgBox: Trying to bypass permision denied error

    Hello,

    Im using ASP with VBScript.
    At some point of the code of the application that Im making some changes, I need to get a confirmation from the user if he wants or not to send a confirmation e-mail for the action he performed.

    Its simple, like this:

    Code:
    sendEmail = MsgBox("Send e-mail?",5,"Confirmation")
    if sendEmail = 6 then
    
    Set objmail = Server.CreateObject("CDONTS.NewMail") 
    			objmail.from = trim(rs("EMAIL"))
    			objmail.Value("Reply-To") = trim(rs("EMAIL"))
    			objmail.to = trim(rs("EMAIL_RESPONSAVEL"))&";"&trim(rs("EMAIL_GRUPO"))
    			objmail.subject = trim(rs("EMAIL_ASSUNTO_FECHAMENTO_RESPONSAVEL"))&" "&trim(rs("NOME_TIPO_DOCUMENTO"))
    			objmail.body = texto 
    			objmail.BodyFormat = 0
    			objmail.Importance = 2	
    			objmail.MailFormat = 0			
    			objmail.send
    		set objmail = nothing
    
    end if
    rs is just a recordset with some data on.

    The thing is like this, I get the old Permission Denied error..
    So I tryed like that, that I dont know is its going to work or not until someone uses this part of the application:

    Code:
    		<SCRIPT language="VBScript">
    		
    		sendEmail = MsgBox("Send e-mail?",5,"Confirmation")
    		
    		if sendEmail = 6 then
    		
    		send = true
                                 
                                    end if
    					
    		</SCRIPT>
    		
    		<%
    		
    		if send = true
    		
    		Set objmail = Server.CreateObject("CDONTS.NewMail") 
    			objmail.from = trim(rs("EMAIL"))
    			objmail.Value("Reply-To") = trim(rs("EMAIL"))
    			objmail.to = trim(rs("EMAIL_RESPONSAVEL"))&";"&trim(rs("EMAIL_GRUPO"))
    			objmail.subject = trim(rs("EMAIL_ASSUNTO_FECHAMENTO_RESPONSAVEL"))&" "&trim(rs("NOME_TIPO_DOCUMENTO"))
    			objmail.body = texto 
    			objmail.BodyFormat = 0
    			objmail.Importance = 2	
    			objmail.MailFormat = 0			
    			objmail.send
    		set objmail = nothing
    		
                                    end if
    		%>
    Moving the MsgBox to run on the client side works, but I dont belive if the 'send' variable created in the client-side code will be seen by the code runned server-side.

    Anyone know some way to get this working?

    Thank you very much in advance!
  • shweta123
    Recognized Expert Contributor
    • Nov 2006
    • 692

    #2
    Hi,

    You can write the code to get the confirmation before sending the email at the client side using javascript function.
    You can do this using following steps :

    1> Create a hidden field in your ASP page and set the value of this hidden field to TRUE or FALSE using javascript function.
    e.g.

    Code:
    <input type="hidden" name= "hidEmail">
    2> Now , Write the javascript function in order to set the value of hidden field .

    Code:
    <script>
    function setEmail()
        {
          //set the hidden field Email
          document.form1.hidEmail.value = confirm("Do you want to send email?");
        }
    </script>
    3> Call the above javascript function on the Submit button.
    e.g.
    Code:
    <Input type = "Submit" onClick =  "setEmail();">
    4> Retrieve the value of the hidden field on The ASP page in order to decide if Email should be sent or not.
    e.g.
    Code:
    <%
               Dim emailconfirm
               emailconfirm = Request. Form("hidEmail")
    
               If(emailconfirm = TRUE) then
                      '''''''''''''''Write the code for sending email   
               End if
               %>

    Comment

    • jim bradshaw
      New Member
      • Feb 2009
      • 4

      #3
      it worked, but...

      I almost gave up on this before I made it work by using "true" instead of TRUE. Thought it might help someone else out. Otherwise, thanks for the useful info. My (working) code:

      <%@ Language=VBscri pt%>
      <%option Explicit%>

      <script language = javascript type = text/javascript>
      function SetDelCN(){
      document.getEle mentById("DelCN ").value = confirm("Are you sure you want to Delete?")
      }</script>

      <%

      sub delcont
      Dim DelContconfirm
      DelContConfirm = Request("DelCN" )
      response.write( DelContConfirm) &"<BR>"
      If(DelContConfi rm = "true") then
      response.write "delete the record" & "<BR>"
      else
      response.write "dont delete the record" & "<BR>"
      end if
      end sub

      execute request("action ")

      %>

      <html>
      <head>
      <title></title>
      </head>
      <body>

      <form name=formx action=testconf irm.asp method=post>
      <input type=hidden name=action value=DelCont>
      <input type=hidden name= DelCN>
      <input size = 3 type=submit name=delrec onclick = SetDelCN() value="Delete">
      </form>

      </body>
      </html>

      Comment

      Working...