atskiii
asked on
Opening Outlook 2003 profile using VBScript.
Hi,
I want to use standalone VBSCRIPT to open an outlook mailbox. After opening it I will excute VBScript code shown below to close that outlook mailbox. Here's the code I'm using, please let me know where I am going wrong.
opening Outlook mailbox code - NOT WORKING
__________________________ __________ __________ __________ _______
Set objOutlook = CreateObject("Outlook.Appl ication") ' Get Outlook
Set objNamespace = objOutlook.GetNamespace("M API") ' Get MAPI
Set objFolder = objNamespace.GetDefaultFol der(olFold erInbox) ' Get inbox
__________________________ __________ __________ __________ _______
Closing Outlook mailbox code - WORKING
__________________________ __________ __________ __________ _______
Set olMAPI = GetObject("", "Outlook.Application").Get Namespace( "MAPI")
olMAPI.Application.Quit
Set olMAPI = Nothing
__________________________ __________ __________ __________ _______
Thanks you for your help.
I want to use standalone VBSCRIPT to open an outlook mailbox. After opening it I will excute VBScript code shown below to close that outlook mailbox. Here's the code I'm using, please let me know where I am going wrong.
opening Outlook mailbox code - NOT WORKING
__________________________
Set objOutlook = CreateObject("Outlook.Appl
Set objNamespace = objOutlook.GetNamespace("M
Set objFolder = objNamespace.GetDefaultFol
__________________________
Closing Outlook mailbox code - WORKING
__________________________
Set olMAPI = GetObject("", "Outlook.Application").Get
olMAPI.Application.Quit
Set olMAPI = Nothing
__________________________
Thanks you for your help.
ASKER
Hi Chris,
Thank you for your help. I have replaced "olFolderInbox" with "6" and error message I used to get, "Could not complete the operation. One or more parameter values are not valid." no longer appears. When executing the code with parameter value "6", nothing seems to happen. What does value "6" represent? I tried "5" because Inbox is the 5th folder in my mailbox. sorry for this silly question. I am new to VBscripting so all seems so obvious to ask.
Thank you for your help again.
Thank you for your help. I have replaced "olFolderInbox" with "6" and error message I used to get, "Could not complete the operation. One or more parameter values are not valid." no longer appears. When executing the code with parameter value "6", nothing seems to happen. What does value "6" represent? I tried "5" because Inbox is the 5th folder in my mailbox. sorry for this silly question. I am new to VBscripting so all seems so obvious to ask.
Thank you for your help again.
In VBA the constant olFolderInbox has a value of 6. VBS does not know the values for VBA constants hence the substitution.
Your snippet:
Set objOutlook = CreateObject("Outlook.Appl ication") ' Get Outlook
Set objNamespace = objOutlook.GetNamespace("M API") ' Get MAPI
Set objFolder = objNamespace.GetDefaultFol der(olFold erInbox) ' Get inbox
establishes a connection to outlook but you cannot see it, objoutlook.visible should render it visble ... if however you are merely doing some processing you would not need it to be visible hence any snippets you saw to create this code may not have needed the visibility of the application.
I could of course be wrong, but that's my first take on the matter, let me know how it goes.
Chris
Your snippet:
Set objOutlook = CreateObject("Outlook.Appl
Set objNamespace = objOutlook.GetNamespace("M
Set objFolder = objNamespace.GetDefaultFol
establishes a connection to outlook but you cannot see it, objoutlook.visible should render it visble ... if however you are merely doing some processing you would not need it to be visible hence any snippets you saw to create this code may not have needed the visibility of the application.
I could of course be wrong, but that's my first take on the matter, let me know how it goes.
Chris
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Most disappointing, I have tested the answer I gave to the original code and indeed replacing the constant with a magic number works, the outlook application is opened and closed again afterwards ... the follow on question whilst not fully resolved was not in the original so closing the Q as self answered is I believe unfair, but for 100 points i'm not about to argue.
Chris
Chris
Try replacing:
Set objFolder = objNamespace.GetDefaultFol
with
Set objFolder = objNamespace.GetDefaultFol
Regards,
chris_bottomley