I've created a .vbs file to create a folder in Outlook. I've copied most of the script right out of MSDN and get an "Expected End of Statement" error code 800A0401 response.
Option Explicit
Dim myNameSpace As Outlook.NameSpace
Dim myFolder As Outlook.Folder
Dim myNewFolder As Outlook.Folder
Set myNameSpace = Application.GetNamespace("MAPI")
Set myFolder = myNameSpace.GetDefaultFolder(olFolderInbox)
Set myNewFolder = myFolder.Folders.Add("Postini")
Wscript.Echo "Folder created"
Wscript.Quit
Never created a .vbs script before. Not sure what I'm missing.
Windows 7 64-bit and Outlook 2010. Running as local administrator.
This error is because you cannot dim variables as something in particular in VBS. Said more explicitly the "Dim" statement is used without defining the variable type in VBScript because all variables in VBScript are automatically of type Variant. If you attempt to Dim a variable as anything, it will throw an error.
Instead, you want:
Additionally, you seem to have just copied some VBA from Outlook and tried to run it as VBS.
VBscript does not know how to interpret
Application.GetNameSpace("MAPI")
.You will need to also create an Outlook Application.
Also, since you cannot provide references in VBS, you have to use late binding for any objects (which is why I used CreateObject.) So re-written your code is as follows: