Thursday, March 22, 2012

working with vbs file

Hello EveryOne,

I am working on VS 2005 and I have made on send-mail.vbs file It contain followin Code

************************************************************

Const cdoOutlookExvbsss = 2
Const cdoIIS = 1

Dim MessageAs New CDO.Message

'Create CDO message objectSet Message = CreateObject("CDO.Message")
With Message
'Load IIS configuration .Configuration.Load cdoIIS'Set email adress, subject And body .To ="to@dotnet.itags.org.emailaddress.com" .Subject ="TESTING" .TextBody ="<H2><FONT COLOR=Red>My BODY TEXT</FONT></H2>"'Set sender address If specified.If Len("from@dotnet.itags.org.emailaddress.com") > 0Then .From ="from@dotnet.itags.org.emailaddress.com"'Send the message .SendEnd With

**********************************************************

I used to run with Windows Task sheduler, When I run this script I got error

----------------

Excepted End of Statement

Line 4

----------------

I have no idea how to crrect it. Please Help me

.Net 2.0 uses the System.Net.Mail namespace...it's replaced CDO.Message.

And take a look atwww.systemnetmail.com for example scripts.

Jeff


are you sure if I use system.net.mail

Const cdoOutlookExvbsss = 2
Const cdoIIS = 1

Dim MessageAs New system.net.mail
'Create CDO message object
Set Message = CreateObject("system.net.mail")
With Message
'Load IIS configuration
.Configuration.Load cdoIIS

'Set email adress, subject And body
.To ="to@.emailaddress.com"
.Subject ="TESTING"
.TextBody ="<H2><FONT COLOR=Red>My BODY TEXT</FONT></H2>"

'Set sender address If specified.
If Len("from@.emailaddress.com") > 0Then .From ="from@.emailaddress.com"

'Send the message
.Send
End With

Is this works? Becoz it is vbs file not .vb file and this will be run by windows sheduler


Make it an EXE, not a VBS.

And it works differently then what you have. Look at the samples that Jeff pointed out.

0 comments:

Post a Comment