Link to home
Start Free TrialLog in
Avatar of Higor
Higor

asked on

ASP TAG in a vbscript

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
Avatar of Higor
Higor

ASKER

Error Type:
Microsoft VBScript runtime (0x800A000D)
Type mismatch

the asp error
Avatar of aelatik
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
%>
Add the "=" sign after the "%" sign to indicate a Response.Write


call EnvoyerMail(<%= CourrielInterne %>,<%= strMessageInterne %>)
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 -
Avatar of Higor

ASKER

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>
Avatar of Higor

ASKER

Server.CreateObject
Server execution failed if i run this code in asp....
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.
Avatar of Higor

ASKER

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....
Avatar of Higor

ASKER

also the <%=MyVar> doesnt work he said, invalid carracter....  at a line thats do anything with my sub
>>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 %>")
Avatar of Higor

ASKER

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>
Avatar of Higor

ASKER

<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>"
Avatar of Higor

ASKER

i'm so lost.....
ASKER CERTIFIED SOLUTION
Avatar of AzraSound
AzraSound
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Higor

ASKER

lol It was only the missing " " thx a lot!!