?
Solved

ASP TAG in a vbscript

Posted on 2003-03-20
15
Medium Priority
?
275 Views
Last Modified: 2010-05-01
Hi,

ok i want to call a vbscript sub in asp, but i also want to pass parameters that are var in asp like this

<%
if(NOT rsEmailInterne.EOF) then
'For my mail
 CourrielInterne = CourrielInterne + rsEmailInterne("Courriel")
 rsEmailInterne.MoveNext
 do while(NOT rsEmailInterne.EOF)
  'for the other mail
   CourrielInterne = CourrielInterne + ", " + rsEmailInterne("Courriel")
   rsEmailInterne.MoveNext
 loop
'sub vbscript with asp parameter
%>
<script language="VBScript">
     call EnvoyerMail(<%CourrielInterne%>,<%strMessageInterne%>)
</script>
<%
end if
%>


its that possible to pass a string in asp, to a vbscript sub ???

thx
0
Comment
Question by:Higor
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
15 Comments
 
LVL 5

Author Comment

by:Higor
ID: 8175101
Error Type:
Microsoft VBScript runtime (0x800A000D)
Type mismatch

the asp error
0
 
LVL 14

Expert Comment

by:aelatik
ID: 8175173
Don't know what you mean, ASP uses VBSCRIPT so what do you mean by passing ASP string to VBSCRIPT : Try..

<%
if(NOT rsEmailInterne.EOF) then
'For my mail
CourrielInterne = CourrielInterne + rsEmailInterne("Courriel")
rsEmailInterne.MoveNext
do while(NOT rsEmailInterne.EOF)
 'for the other mail
  CourrielInterne = CourrielInterne + ", " + rsEmailInterne("Courriel")
  rsEmailInterne.MoveNext
loop
'sub vbscript with asp parameter
call EnvoyerMail(CourrielInterne,strMessageInterne)
end if
%>
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 8175223
Add the "=" sign after the "%" sign to indicate a Response.Write


call EnvoyerMail(<%= CourrielInterne %>,<%= strMessageInterne %>)
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 14

Expert Comment

by:CyrexCore2k
ID: 8175232
The code above should do what ur talking about except you made a little coding error:

- Start Code -
<%
if(NOT rsEmailInterne.EOF) then
'For my mail
CourrielInterne = CourrielInterne + rsEmailInterne("Courriel")
rsEmailInterne.MoveNext
do while(NOT rsEmailInterne.EOF)
 'for the other mail
  CourrielInterne = CourrielInterne + ", " + rsEmailInterne("Courriel")
  rsEmailInterne.MoveNext
loop
'sub vbscript with asp parameter
%>
<!-- This is your code
<script language="VBScript">

    call EnvoyerMail(<%CourrielInterne%>,<%strMessageInterne%>)
</script> -->
<!-- Put this instead -->
<script language="VBScript">
    call EnvoyerMail(<%=CourrielInterne%>,<%=strMessageInterne%>)
</script>
<%
end if
%>
- End Code -
0
 
LVL 5

Author Comment

by:Higor
ID: 8176102
It give me 2 error, in vvbscript...

here my sub in vbscript, but i want if its possible to run it from the server, but i think i have some activex problem, because its the error
Server object
Server execution failed....


<script language="VBScript">
     sub EnvoyerMail(Courriel,strMessage)
          Dim myOutlookApli
          Dim mynamespace
          Dim mycontent
               Set myOutlookApli = CreateObject("Outlook.Application")
          Set mynamespace = myOutlookApli.GetNamespace("MAPI")
          Set mycontent = myOutlookApli.Createitem(0)
          mycontent.To = Courriel
          mycontent.Subject ="test"
          mycontent.HTMLBody = strMessage
          mycontent.Attachments.Add "C:\logoBienvenue.jpg"
          mycontent.send
          myOutlookapli.Quit
     end sub
     
</script>
0
 
LVL 5

Author Comment

by:Higor
ID: 8176107
Server.CreateObject
Server execution failed if i run this code in asp....
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 8176191
That function will run on the client's machine.  If you want it to run on the server you need to return back to the server (via posting the current html page or the like) and running that function on the server within asp tags.

Office automation on the server is not supported by MS, however.  You should look to CDONTS for sending mail from the server.
0
 
LVL 5

Author Comment

by:Higor
ID: 8176209
ya i know, but the problem with CDONT, is that it use smtp, and my email is on a microsoft exchange server who use MAPI.... i've try with CDONT and it works for external email but not internal....
0
 
LVL 5

Author Comment

by:Higor
ID: 8176217
also the <%=MyVar> doesnt work he said, invalid carracter....  at a line thats do anything with my sub
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 8176236
>>also the <%=MyVar> doesnt work he said, invalid carracter....  at a line thats do anything with my sub

Then why would it be a problem with the <%= MyVar %> syntax?  I would guess its a problem at the line number specified.

Now that I look at it, if it's a string being passed in, you still need to indicate that in your client script, e.g.,

call EnvoyerMail("<%= CourrielInterne %>", "<%= strMessageInterne %>")
0
 
LVL 5

Author Comment

by:Higor
ID: 8176260
like this:??? im not suppose to said as string in vbscript....
whats the problem with this?

<script language="VBScript">
     sub EnvoyerMail(courrier,message)
          Dim myOutlookApli
          Dim mynamespace
          Dim mycontent

          Set myOutlookApli = CreateObject("Outlook.Application")
          Set mynamespace = myOutlookApli.GetNamespace("MAPI")
          Set mycontent = myOutlookApli.Createitem(0)
          mycontent.To = courrier
          mycontent.Subject ="test"
          mycontent.HTMLBody = message
          mycontent.Attachments.Add "C:\logoBienvenue.jpg"
          mycontent.send
          myOutlookapli.Quit
     end sub
     
</script>
0
 
LVL 5

Author Comment

by:Higor
ID: 8176308
<script language="VBScript">
                                                  call EnvoyerMail(<%= CourrielInterne%>,<%= strMessageInterne%>)
                                             </script>

i dont see non valid caracter here also here my var CourrielInter:
CourrielInterne = CourrielInterne + rsEmailInterne("Courriel")
                                             rsEmailInterne.MoveNext
                                             do while(NOT rsEmailInterne.EOF)
                                                  'Pour les mails suivants
                                                  CourrielInterne = CourrielInterne + ", " + rsEmailInterne("Courriel")
                                                  rsEmailInterne.MoveNext
                                             loop
strMessageInterne = "<html><body>" _      
                                             & "<table border=0><tr><td><font size=4 color=#003366>Bonjour et bon lundi, <br><br>" _
                                             & "Cette semaine il y a des anniversaires à souligner!<br> " _
                                             & "DTI vous invite à aller visiter </font><a href='http://proxynt/test_intranet'><font size=4 color=#0099CC>l'intranet</font></a>" _
                                             & " <font size=4 color=#003366> pour connaître les nouveaux jubilés.</font>" _
                                             & "</td></tr></table></body></html>"
0
 
LVL 5

Author Comment

by:Higor
ID: 8176324
i'm so lost.....
0
 
LVL 28

Accepted Solution

by:
AzraSound earned 80 total points
ID: 8176401
In your asp page, make sure it says this:

call EnvoyerMail("<%= CourrielInterne %>", "<%= strMessageInterne %>")


After you view the page in your browser, view the html source and see what that line actually says and if it complies with what you think you should be seeing.
0
 
LVL 5

Author Comment

by:Higor
ID: 8176461
lol It was only the missing " " thx a lot!!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses
Course of the Month10 days, left to enroll

762 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