Sending an email message from a batch vbs script |
Marius - Roma posted on Wednesday, January 27, 2010 4:01 PM
|
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 |
 |
|
|
|
"Marius - Roma" |
Pegasus [MVP] replied to Marius - Roma on Wednesday, January 27, 2010 6:04 PM
|
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 = "James@company.com"
.To = "Jim@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") = "James@company.com"
.Item (schema & "smtpaccountname") = "James@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. |
 |
|
CDO refinement |
Frank Van Staveren replied to Pegasus [MVP] on Wednesday, February 03, 2010 6:10 AM
|
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? |
 |
|
|
|
|
Didn't Find The Answer You Were Looking For? |
| View VBScript Posts Ask A New Question |
|
| EggHeadCafe has experts online right now that may know the answer to your question. We pay them a bonus for answering as many questions as they can. So, why not help them and yourself by becoming a member (free) and ask them your question right now? |
| Create Account & Ask Question In Live Forum |
|
| Previous VBScript conversation. |