logo

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
reply


"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.
reply

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?
reply


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.

.NET Distributed Applications    .NET Framework    ADO.NET    ASP.NET    ASP.NET Security    ASP.NET Web Controls    ASP.NET Web Services    .NET CLR    .NET Compact Framework    .NET Drawing GDI+    .NET COM Interop    .NET Performance    .NET Web Services    .NET Windows Forms    .NET WinForms Controls    .NET    C#    VB.NET    VC++.NET    .NET Security    Xml    Visual Studio .NET Debugging    Xml    Xsl    JScript    VBScript    WSH    Smart Phone Developer    VB COM    VB Controls    VB Crystal    VB DataBase ADO    VB Syntax    VB WinAPI    VC ATL    VC Debugger    VC Language    VC MFC    VC STL    Visio Developer VBA    WindowsCE Embedded VC    Powershell    .NET Microframework    VB Vista Compatibility    Deployment Server    .NET Microframework Porting   




  $1000    Adam Houldsworth - $173  |  Jonathan VH - $154  |  Kirtan Patel - $116  |  Mr. Khan - $99  |  F Cali - $94  |  more Neado  |  Free Icons  |  Privacy  |   (c) 2010