Help | Site Map
Connecting Tech Pros Worldwide
Reply
 
LinkBack Thread Tools
  #1  
Old October 7th, 2008, 03:54 PM
Newbie
 
Join Date: Oct 2008
Posts: 1
Default 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:

Expand|Select|Wrap|Line Numbers
  1. sendEmail = MsgBox("Send e-mail?",5,"Confirmation")
  2. if sendEmail = 6 then
  3.  
  4. Set objmail = Server.CreateObject("CDONTS.NewMail") 
  5.             objmail.from = trim(rs("EMAIL"))
  6.             objmail.Value("Reply-To") = trim(rs("EMAIL"))
  7.             objmail.to = trim(rs("EMAIL_RESPONSAVEL"))&";"&trim(rs("EMAIL_GRUPO"))
  8.             objmail.subject = trim(rs("EMAIL_ASSUNTO_FECHAMENTO_RESPONSAVEL"))&" "&trim(rs("NOME_TIPO_DOCUMENTO"))
  9.             objmail.body = texto 
  10.             objmail.BodyFormat = 0
  11.             objmail.Importance = 2    
  12.             objmail.MailFormat = 0            
  13.             objmail.send
  14.         set objmail = nothing
  15.  
  16. 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:

Expand|Select|Wrap|Line Numbers
  1.         <SCRIPT language="VBScript">
  2.  
  3.         sendEmail = MsgBox("Send e-mail?",5,"Confirmation")
  4.  
  5.         if sendEmail = 6 then
  6.  
  7.         send = true
  8.  
  9.                                 end if
  10.  
  11.         </SCRIPT>
  12.  
  13.         <%
  14.  
  15.         if send = true
  16.  
  17.         Set objmail = Server.CreateObject("CDONTS.NewMail") 
  18.             objmail.from = trim(rs("EMAIL"))
  19.             objmail.Value("Reply-To") = trim(rs("EMAIL"))
  20.             objmail.to = trim(rs("EMAIL_RESPONSAVEL"))&";"&trim(rs("EMAIL_GRUPO"))
  21.             objmail.subject = trim(rs("EMAIL_ASSUNTO_FECHAMENTO_RESPONSAVEL"))&" "&trim(rs("NOME_TIPO_DOCUMENTO"))
  22.             objmail.body = texto 
  23.             objmail.BodyFormat = 0
  24.             objmail.Importance = 2    
  25.             objmail.MailFormat = 0            
  26.             objmail.send
  27.         set objmail = nothing
  28.  
  29.                                 end if
  30.         %>
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!
Reply
  #2  
Old October 7th, 2008, 04:59 PM
shweta123's Avatar
Expert
 
Join Date: Nov 2006
Location: India,Pune
Age: 29
Posts: 657
Default

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.

Expand|Select|Wrap|Line Numbers
  1. <input type="hidden" name= "hidEmail">
2> Now , Write the javascript function in order to set the value of hidden field .

Expand|Select|Wrap|Line Numbers
  1. <script>
  2. function setEmail()
  3.     {
  4.       //set the hidden field Email
  5.       document.form1.hidEmail.value = confirm("Do you want to send email?");
  6.     }
  7. </script>
3> Call the above javascript function on the Submit button.
e.g.
Expand|Select|Wrap|Line Numbers
  1. <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.
Expand|Select|Wrap|Line Numbers
  1. <%
  2.            Dim emailconfirm
  3.            emailconfirm = Request. Form("hidEmail")
  4.  
  5.            If(emailconfirm = TRUE) then
  6.                   '''''''''''''''Write the code for sending email   
  7.            End if
  8.            %>
Reply
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles