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(<%CourrielInte rne%>,<%st rMessageIn terne%>)
</script>
<%
end if
%>
its that possible to pass a string in asp, to a vbscript sub ???
thx
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(<%CourrielInte
</script>
<%
end if
%>
its that possible to pass a string in asp, to a vbscript sub ???
thx
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(CourrielIntern e,strMessa geInterne)
end if
%>
<%
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(CourrielIntern
end if
%>
Add the "=" sign after the "%" sign to indicate a Response.Write
call EnvoyerMail(<%= CourrielInterne %>,<%= strMessageInterne %>)
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(<%CourrielInte rne%>,<%st rMessageIn terne%>)
</script> -->
<!-- Put this instead -->
<script language="VBScript">
call EnvoyerMail(<%=CourrielInt erne%>,<%= strMessage Interne%>)
</script>
<%
end if
%>
- End Code -
- 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(<%CourrielInte
</script> -->
<!-- Put this instead -->
<script language="VBScript">
call EnvoyerMail(<%=CourrielInt
</script>
<%
end if
%>
- End Code -
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,strMe ssage)
Dim myOutlookApli
Dim mynamespace
Dim mycontent
Set myOutlookApli = CreateObject("Outlook.Appl ication")
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>
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,strMe
Dim myOutlookApli
Dim mynamespace
Dim mycontent
Set myOutlookApli = CreateObject("Outlook.Appl
Set mynamespace = myOutlookApli.GetNamespace
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>
ASKER
Server.CreateObject
Server execution failed if i run this code in asp....
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.
Office automation on the server is not supported by MS, however. You should look to CDONTS for sending mail from the server.
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....
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 %>")
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 %>")
ASKER
like this:??? im not suppose to said as string in vbscript....
whats the problem with this?
<script language="VBScript">
sub EnvoyerMail(courrier,messa ge)
Dim myOutlookApli
Dim mynamespace
Dim mycontent
Set myOutlookApli = CreateObject("Outlook.Appl ication")
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>
whats the problem with this?
<script language="VBScript">
sub EnvoyerMail(courrier,messa
Dim myOutlookApli
Dim mynamespace
Dim mycontent
Set myOutlookApli = CreateObject("Outlook.Appl
Set mynamespace = myOutlookApli.GetNamespace
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>
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>"
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 size=4 color=#003366> pour connaître les nouveaux jubilés.</font>" _
& "</td></tr></table></body>
ASKER
i'm so lost.....
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
lol It was only the missing " " thx a lot!!
ASKER
Microsoft VBScript runtime (0x800A000D)
Type mismatch
the asp error