Discussion:
Sending an email message from a batch vbs script
(too old to reply)
Marius - Roma
2010-01-27 21:01:26 UTC
Permalink
I need to create a vbscript to be scheduled as a batch job to send a
specific file to a given recipient every night.
Outlook is installed on the Windows XP Pc where the script should be
scheduled, but no user interaction is available (the script should be
scheduled to run during the night).
What is the best method I should use to create and send the message?
Is there any sample I can start from?
Regards
Marius
Pegasus [MVP]
2010-01-27 23:04:10 UTC
Permalink
Post by Marius - Roma
I need to create a vbscript to be scheduled as a batch job to send a
specific file to a given recipient every night.
Outlook is installed on the Windows XP Pc where the script should be
scheduled, but no user interaction is available (the script should be
scheduled to run during the night).
What is the best method I should use to create and send the message?
Is there any sample I can start from?
Regards
Marius
If you want a batch solution then blat.exe (which you can download from a
number of sites) is the simplest solution to send an EMail message.

If you want a VB Script file then you could do it like so:

const cdoBasic=1
schema = "http://schemas.microsoft.com/cdo/configuration/"
Set objEmail = CreateObject("CDO.Message")
With objEmail
.From = "***@company.com"
.To = "***@company.com"
.Subject = "Test Mail"
.Textbody = "The quick brown fox " & Chr(10) & "jumps over the lazy dog"
.AddAttachment "d:\Testfile.txt"
With .Configuration.Fields
.Item (schema & "sendusing") = 2
.Item (schema & "smtpserver") = "mail.company.com"
.Item (schema & "smtpserverport") = 25
.Item (schema & "smtpauthenticate") = cdoBasic
.Item (schema & "sendusername") = "***@company.com"
.Item (schema & "smtpaccountname") = "***@company.com"
.Item (schema & "sendpassword") = "SomePassword"
End With
.Configuration.Fields.Update
.Send
End With

Neither the batch file nor the VB Script file solution relies on Outlook or
any other local mail client.
unknown
2010-02-03 11:10:09 UTC
Permalink
That works, but I wondering how to send an appointment/meeting using the smae methods, with an ics attachment. I cdan deo the attachment, but the headers read email on the receiving end, not as a calendar item. How do I change it?



Pegasus [MVP] wrote:

"Marius - Roma" <***@nospam.
27-Jan-10

"Marius - Roma" <***@nospam.local> said this in news ite

If you want a batch solution then blat.exe (which you can download from
number of sites) is the simplest solution to send an EMail message

If you want a VB Script file then you could do it like so

const cdoBasic=
schema = "http://schemas.microsoft.com/cdo/configuration/
Set objEmail = CreateObject("CDO.Message"
With objEmai
.From = "***@company.com
.To = "***@company.com
.Subject = "Test Mail
.Textbody = "The quick brown fox " & Chr(10) & "jumps over the lazy dog
.AddAttachment "d:\Testfile.txt
With .Configuration.Field
.Item (schema & "sendusing") =
.Item (schema & "smtpserver") = "mail.company.com
.Item (schema & "smtpserverport") = 2
.Item (schema & "smtpauthenticate") = cdoBasi
.Item (schema & "sendusername") = "***@company.com
.Item (schema & "smtpaccountname") = "***@company.com
.Item (schema & "sendpassword") = "SomePassword
End Wit
.Configuration.Fields.Updat
.Sen
End Wit

Neither the batch file nor the VB Script file solution relies on Outlook o
any other local mail client.

Previous Posts In This Thread:


Submitted via EggHeadCafe - Software Developer Portal of Choice
KB905915 may break Internet Explorer
http://www.eggheadcafe.com/tutorials/aspnet/fc90956d-fdb7-4cab-bb52-0ca06c03016c/kb905915-may-break-intern.aspx
Loading...