Newbie VB script question
Posted on 2005-04-18
OK - embarrassing question.
I'm used to writing VB(A) in an Access/SQL enviornment. *stop sniggering at the back*
However, I've got an urgent need for a 'stand alone' script that will open up Outlook and create an email from a command line or something like that. (.vbs file?)
Is this possible ? The clients are running XP so I think they natively understand vb ...
Basically, I want something like the below to be 'runnable' or call-able from a command line - as a stand alone 'program' (if parameters cannot be passed, that is no problem)
Sub SendMailOutlook(aTo, Subject, TextBody, aFrom)
'Create an Outlook object
Dim Outlook As New Outlook.Application
Set Outlook = CreateObject("Outlook.Application")
'Create e new message
Dim Message As Outlook.MailItem
Set Message = Outlook.CreateItem(olMailItem)
.Subject = Subject
.Body = TextBody
'Set destination email address
'Set sender address If specified.
Const olOriginator = 0
If Len(aFrom) > 0 Then .Recipients.Add(aFrom).Type = olOriginator
'Send the message