Real’s Howto WSH VBScript

Reals Howto WSH VBScriptThese How-to’s are about the usage of VBScript used with the Window Scripting Host (WSH). WSH enables scripts to be executed directly on the Windows desktop or command console, without the need to embed those scripts in an HTML document. Scripts can be run directly from the desktop simply by clicking on a script file ( .vbs for VBScript), or from the command console. The WSHost is included with all recent Windows versions or it can be freely downloaded from Microsoft or here


Send email with Outlook (MAPI)
[sendemail.vbs]
Dim ToAddress
Dim MessageSubject
Dim MessageBody
Dim MessageAttachment
Dim ol, ns, newMail
ToAddress = “Gagnon, RĂ©al” ‘ change this…
MessageSubject = “VBS MAPI HowTo”
MessageBody = “*BODY* email via MAPI *BODY*”
Set ol = WScript.CreateObject(”Outlook.Application”)
Set ns = ol.getNamespace(”MAPI”)
ns.logon “”,”",true,false
Set newMail = ol.CreateItem(olMailItem)
newMail.Subject = MessageSubject
newMail.Body = MessageBody &vbCrLf
‘ validate the recipient, just in case…
Set myRecipient = ns.CreateRecipient(ToAddress)
myRecipient.Resolve
If Not myRecipient.Resolved Then
MsgBox “unknown recipient”
Else
newMail.Recipients.Add(myRecipient)
newMail.Send
End If
Set ol = Nothing

Website: www.edgewordstraining.co.uk | Filesize: 36kb
No of Page(s): 16

Click here to download Real’s Howto WSH VBScript

Related Tutorial

Tags:

Comments

Leave a Reply