Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - VBScript and CDOSYS

Reply
 
Old 08-12-2008   #1 (permalink)
paulmitchell507


 
 

VBScript and CDOSYS

I am using CDOSYS to send emails containing variables that have been
enetered via a form on as asp page. Until now, each variable has
contained a single value, as shown below.

<%@ Language="VBScript" %>
<% Option Explicit %>
<html>
<head>
<title>Request Emailed</title>
</head>
<body>

<%
'Declare variables
Dim sch, cdoConfig, cdoMessage, holiday_ID, email, auth, id,
firstlastname, startdate, enddate, email_sent, NumberofDays, AMPM,
AMPMDate, DaysifAuthorised
email_sent = -1
enddate = Request.Form("enddate")
startdate = Request.Form("startdate")
firstlastname = Request.Form("firstlastname")
holiday_ID = Request.Form("myname")
NumberofDays = Request.Form("NumberofDays")
AMPM = Request.Form("AMPM")
AMPMDate = Request.Form("AMPMDate")
DaysifAuthorised = Request.Form("DaysifAuthorised")
sch = "http://schemas.microsoft.com/cdo/configuration/"

Set cdoConfig = CreateObject("CDO.Configuration")

With cdoConfig.Fields
'Set CDO Port
.Item(sch & "sendusing") = 2
'Set mailserver name either IP address, mail.yoursite.com or
localhost
.Item(sch & "smtpserver") = "192.156.217.6"
'Set SMTP port which is 25 by default
.Item(sch & "smtpserverport") = 25
'Set number of seconds before timeout
.Item(sch & "smtpconnectiontimeout") = 60
.update
End With

Set cdoMessage = CreateObject("CDO.Message")

With cdoMessage
Set .Configuration = cdoConfig
.From = "administrator@xxxxxx"
.To = "paul@xxxxxx"
.Subject = ""& holiday_ID
'Send the email in HTML format
.HTMLBody = "Name of Applicant:" & firstlastname &
"<br>Holiday Start Date:&nbsp;" & startdate & "<br>Holiday End
Date:&nbsp;" & enddate & "<br>Number of Working Days:" & NumberofDays
& AMPM & AMPMDate & "<br>Leave oustanding:&nbsp;" & DaysifAuthorised
&"<br><a href='http://192.156.217.134/authorise.asp?id="& holiday_ID
&"'>Authorise Holiday Request</a><br><br><a href='http://
192.156.217.134/authorise.asp?id="& holiday_ID &"'>delete record</
a><br><br>"
.Send
End With

Set cdoMessage = Nothing
Set cdoConfig = Nothing

Now I would like to add to the body of the email a ADO Recordset
object. I would normally display the results in a html table,

%><table border="1" width="100%">
<%do until rs.EOF%>
<tr>
<%for each x in rs.Fields%>
<td><%Response.Write(x.value)%></td>
<%next
rs.MoveNext%>
</tr>
<%loop
rs.close
conn.close
%>

Do you know how I can include this in my email?
Regards,

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
New to VBscript, Help please! VB Script
cdosys.dll xp and vista different? General Discussion
CSS and VBscript VB Script
Where is VBscript now? VB Script
How to do No hang up VBScript (nohup for VBScript) VB Script


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46