Background/Issue/Question
I just installed Outlook 2013 (64-bit) on my Windows 7 (64-bit) machine and I'm using the developer version of Outlook Redemption to test it out with Outlook 2013 after successfully using it for development with Outlook 2010. I downloaded the newest Redemption files and used the installer to install and register the DLLs.
Now, when I try to run a VBScript against Redemption using WScript.exe or CScript.exe, WScript/CScript crash.
Does anyone know why WScript/CScript would be crashing (see details below)?
Code
Here's my code:
Set Session = CreateObject("Redemption.RDOSession")
WScript.Echo "Session created."
WScript.Echo Session.Version
Session.Logon("Outlook")
WScript.Echo "Logged on with default profile."
Session.Logoff
Error
The code fails when it gets to Session.Logon("Outlook"). Here's the error message I'm receiving and some additional details:
Microsoft Windows Based Script Host has stopped working
Problem details
-------------------
Problem Event Name: APPCRASH
Application Name: WScript.exe
Application Version: 5.8.7601.18283
Application Timestamp: 5258a6e6
Fault Module Name: mso.dll
Fault Module Version: 0.0.0.0
Fault Module Timestamp: 567a40e6
Exception Code: c0000005
Exception Offset: 000000000135991f
OS Version: 6.1.7601.2.1.0.256.4
Troubleshooting
I tried renaming MSO.dll and repairing Outlook, but that had no effect. I also tried re-creating the default profile (called 'Outlook'), but that also had no effect.
I also tried installing Redemption using regsvr32.exe.
I ensured that I was using the 64-bit version of WScript.exe and CScript.exe.
For the sake of posterity, I tested to find out if I could connect to MAPI with Redemption. Here's the code:
Set Outlook = CreateObject("Outlook.Application")
Set Session = Outlook.GetNamespace("MAPI")
Session.Logon("Outlook")
Set rdoSession = CreateObject("Redemption.RDOSession")
WScript.Echo "RDOSession created."
WScript.Echo rdoSession.Version
rdoSession.MAPIOBJECT = Session.MAPIOBJECT
WScript.Echo "RDOSession MAPIOBJECT created."
rdoSession.Logoff
Session.Logoff
The above code works fine in both WScript.exe and CScript.exe, probably because the Outlook Object Model is being used to create the Outlook session and Redemption is just hooking in.
Note -- I can't use the last bit of code for what I plan on doing because the above code won't work from Windows Task Scheduler if my machine is locked or I'm logged off (it only works if I'm logged on). I should point out that the first code snippet worked fine with Outlook 2010, although I was running Outlook 2010 32-bit with Windows 7 64-bit. For Outlook 2013, I decided to move to 64-bit.
Related
I have an issue with an auto start of Outlook 2016 at boot/log on which is intended to start Outlook minimised to the Windows system tray, such that once invoked at Windows 10 launch mail will be collected by the mail account(s) (NB. All POP in this case.) whilst the program resides in the system tray remaining invisible until required by the user.
The .vbs script below does function as required but much of the time it introduces two unwelcome issues.
The Outlook icon in the System Tray displays a 'cog' overlay with the message "Another program is using Outlook. To disconnect programs and exit Outlook, click the Outlook icon and then click Exit Now".
Attempts to open Outlook from the 'Open Outlook' context menu (right click Outlook icon in the tray) item causes a dialogue box to appear reporting "No active explorer object found". Clicking the "OK" option in response launches Outlook (though issue 1 - cog overlay) remains.
Neither issue is present when Outlook is started normally from the desktop so it would appear that the .vbs script is in someway responsible. I have used this script successfully (see also below: https://superuser.com/questions/467809/start-outlook-automatically-in-tray) in the past both as a startup menu shortcut and a hkcu 'run' registry entry.
Can anyone suggest the cause or alternately a suitable code revision to achieve correct function? In case it is significant, Windows 10 is 64 bit Pro and the version of Office (including Outlook) installed is also 64 bit.
This is the code invoked by the .vbs script:
OPTION EXPLICIT
OPTION EXPLICIT
CONST PATH_TO_OUTLOOK = """C:\Program Files\Microsoft Office\Office16\OUTLOOK.EXE"""
CONST SHOW_MAXIMIZED = 3
CONST MINIMIZE = 1
DIM shell, outlook
SET shell = WScript.CreateObject("WScript.Shell")
' Open Outlook
shell.Run PATH_TO_OUTLOOK, SHOW_MAXIMIZED, FALSE
ON ERROR RESUME NEXT
' Grab a handle to the Outlook Application and minimize
SET outlook = WScript.CreateObject("Outlook.Application")
WScript.Sleep(100)
outlook.ActiveExplorer.WindowState = SHOW_MAXIMIZED
' Loop on error to account for slow startup in which case the
' process and/or the main Outlook window is not available
WHILE Err.Number <> 0
Err.Clear
WScript.Sleep(100)
SET outlook = NOTHING
SET outlook = WScript.CreateObject("Outlook.Application")
outlook.ActiveExplorer.WindowState = MINIMIZE
WEND
ON ERROR GOTO 0
SET outlook = NOTHING
SET shell = NOTHING
Having spent a number of hours on this issue over the weekend I thought that I had resolved the issues and got everything functioning as intended.
Working from similar samples of code I compiled a new script (see below) which I applied both as a shortcut in the Startup folder and also as an entry into the 'run' branch of the HKCU registry.
Now for the issue! Testing the script on two separate Windows 10 Pro (both 64 Bit architecture) systems both with Outlook 2016 64 Bit installed as part of a 64 Bit Office suite I found that whereas on one system the script runs flawlessly on the other I receive the following runtime error:
Script: D:\Neil's Files\Neil's Filing Cabinet\Neil's Emails\Start Outlook Minimised to Tray\Start Outlook 2016 Minimised To Tray.vbs
Line: 11
Char: 5
Error: ActiveX component can't create object: 'GetObject'
Code: 800A01AD
Source: Microsoft VBScript runtime error
This has me perplexed as the script file and it's related shortcut are both physical copies of each other given that the revised script below contains no path references (as these are handled directly by the code in respect of Outlook.exe) which are identified by the placement of either the shortcut or as the data element of the registry string whichever format is used.
The Systems do have some differences however and for comparative purposes I will summarise those I feel to be relevant here:
System 1: (The problem system) is an X58 Asus P6T7, Intel i720 mature PC with many programs installed and specifically the Outlook 2016 has the same 12 addins installed but in addition has two related programs which launch at boot, the enterprise editions of 4team's Sync2 for Microsoft Outlook and Safe PST Backup. The boot times are quite lengthy (but acceptable) as is the Outlook Startup with it's various addins.
System 2: Is a current generation Asus X99-Deluxe, i7 5930 new build pc with little installed as yet save MS Office, Adobe CC and some utilities.
In the case of System 1, Outlook auto-starts as intended however during it's loading splash screen (whilst it is loading up the addins) the runtime error is displayed although Outlook continues to open fully but fails to minimise.....
This suggests to me that the faulting code is the section which activates the window however the above error message refers to "ActiveX component can't create object: 'GetObject'" which suggests instead an issue with the code line "Set OLObj = GetObject("","Outlook.Application")"??
Hopefully somebody can test the code on a similar setup and report back? Or alternately, give me a pointer as to what is going on and how I might resolve it. I would of course also welcome any suggested improvements to the code!
** Quick Update ** Now tested on HP Elitebook 8440P Laptop - Windows 10 Pro 64 Bit with Office 64 Bit + same 12 Outlook Addons - Functions as intended.....
** Further Update ** Tested on a second HP Elitebook 8440P Laptop - Windows 10 Pro 64 Bit with Office 64 Bit + same 12 Outlook Addons - Above RunTime error experienced once again.......struggling to comprehend why these results are occurring?? Any thoughts anybody???
The code below is offered "as is" for the benefit of anyone else seeking the same Outlook auto start criteria. The testing with System 2 indicates that it works so I hope others enjoy similar success until the outstanding issues are sorted.
NB: To adjust the Outlook Launch Window Size (during its 10 second pause prior to automated minimising) to reflect personal preferences change the numeric value in the following line of code:
WshShell.Run "OUTLOOK.EXE" , 3, false
For a maximised window size change the value to 3 For a restored window size change the value to 2
OPTION EXPLICIT
Dim WshShell
Dim OLObj
Set WshShell = WScript. CreateObject ( "Wscript.Shell" )
'Open Outlook: Note that inspite of the launch options, it will open the program in a normal window.
'The file location path is not necessary as Windows 10 correctly identifies Outlook's location.
WshShell.Run "OUTLOOK.EXE" , 3, false
'This will mimimise it to the system tray after a 10 second pause to allow for mail collection on Outlook launch.
WScript.Sleep (10000)
Set OLObj = GetObject("","Outlook.Application")
'Activates the window
OLObj.ActiveExplorer.Activate
'Sends the command to minimise
OLObj.ActiveExplorer.WindowState = 1
'Outlook does not immediately minimise to the system tray so that 'Send/Receive' can initiate mail collection.
Thanks to jrv from Microsoft's "The Scripting Guys" forum who kindly offered a revised (simplified) code which is below. I can report that as with the original code it works flawlessly on the same 2 systems as before, whilst faulting once more on the other two......very much perplexed!!
The Runtime Error:
Script: D:\Neil's Files\Neil's Filing Cabinet\Neil's Emails\Start Outlook Minimised to Tray\Start Outlook 2016 Minimised To Tray.vbs
Line: 3
Char: 5
Error: ActiveX component can't create object: 'Outlook.Application'
Code: 800A01AD
Source: Microsoft VBScript runtime error
The revised code:
Set WshShell = CreateObject ( "Wscript.Shell" )
WshShell.Run "OUTLOOK.EXE" , 3, False
Set ol = CreateObject("Outlook.Application")
ol.ActiveExplorer.Activate
ol.ActiveExplorer.WindowState = 1
You can use like file *.reg:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run]
"Outlook"="C:\\Windows\\system32\\cmd.exe /c \"start \"\" /min \"C:\\Program Files\\Microsoft Office\\Office16\\OUTLOOK.EXE\"\""
[HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Outlook\Preferences]
"MinToTray"=dword:00000001
I have an answer that works well with Office 2013 on Windows 7, and I hope it works for you too.
Essentially, this solution bypasses the issue with trying to force Outlook to minimize after loading. Instead, it relies on using a shortcut that's already configured to load the program in a minimized state.
Copy a shortcut to Outlook into the directory containing your script.
Right click the shortcut and open Properties.
In the Shortcut tab, change the Run mode to Minimized. Press OK.
Then, all you need to do in your VBScript file is to execute the shortcut like so:
Dim sh : Set sh = CreateObject("WScript.Shell")
sh.run "Outlook.lnk"
Note that because this solution uses a shortcut, you could potentially remove the VBScript part entirely by putting the shortcut into the All Users Startup folder.
It's me again! I have an answer that should bypass any issues with VBScript by using third-party software, DisplayFusion. I don't know how you'll feel about that, but I tested it and it works over here. I use this at home and at work to manage multiple monitors and various other things. It may even help solve problems with other programs you use and render various VBS hacks redundant.
In your case, there is a feature called 'Triggers'. Note that while there is a free version of DF, you'll have to activate a 30 day trial for the Pro version to use Triggers, and after that, it's up to you to decide if it's worth your while.
Firstly, after installing DF, you'll want to open up its settings window (right-click desktop and go to DisplayFusion > Settings).
Go to the Triggers tab and click Add.
Set up the trigger for when a window is created. Tell the trigger to activate only once per process ID so it won't also try to minimize subsequent windows, such as when composing a new email. Find the path to your outlook.exe. Then, add an action on the right-hand side to minimize the window.
Click OK twice and then see if it works by loading Outlook. For me, the splash screen appears as normal, then the main window is minimized as soon as it appears.
DF runs as a system service with admin privileges and has been tested with tonnes of software packages, so if this method also fails for you, it could indicate bigger issues with your system/Office configuration.
We are upgrading our server to Windows 2012 from 2003.
Our application use CDO 1.21 and MAPI to send mails, I know I have to use SMTP/ OOM/AWS. At this late stage I don't want to do make changes in our programs right now - there are 80+ :)
When I am going to MS site to download CDO 1.21, Windows 2102/Exchange Server 2010 SP3 is not specified under supported platforms.
I am able to download CDO 1.21 for Win 2012. But now when I am connecting via MAPI, System is throwing error:
The information store could not be opened. [MAPI 1.0 - [MAPI_E_LOGON_FAILED(80040111)]]
MAPI Code :
Set objMAPI = New MAPI.Session
objMAPI.Logon ShowDialog:=False, NewSession:=False, ProfileInfo:=gobjINI.gstrExchangeServer & vbLf & gobjINI.gstrProfile
'Add a new mesage to the OUtbo Messages Collection
Set objMSG = objMAPI.Outbox.Messages.Add
Error is thrown on third line: Set objMSG = objMAPI.Outbox.Messages.Add.
I'm in the process of migrating a classic ASP site on an old 32bit XP server to a w7 64 bit. The application works fine where it is currently hosted.
When migrated, I get errors in the global.asa file:
Sub Session_OnStart
'works fine
Set Session("GaoAppEnv")=Server.CreateObject("GaoCommon.AppEnv.1")
'error
Set Session("GaoSession")=Session("GaoAppEnv").CreateSession("file.tps")
...
With the error:
Gao Subsystem error '80020009'
Unknown Exception
I tried to add some error catching code into the vb script around the problem area, but when I try to do WScript.Echo I get yet another error "Object required: 'WScript'"
I've added the registry settings for GaoCommon.AppEnv.1 via DLL, but file.tps seems to be only be a path in the registry to the file itself, and looks to be XML and not what I've seen for a tps filetype online.
It looks as though I've missed something in the migration over, any thoughts?
UPDATE- Things I've already done/checked:
App pool is 32bit
Registry has been updated with both file.tps and GaoCommon.AppEnv.1
First you will need to ensure your ASP runs in a 32-bit Application Pool on the IIS Server for backward compatibility.
Launch Internet Information Services (IIS) Manager.
In the Connections pane, click "Application Pools".
Highlight the application pool for your application, then click "Advanced Settings..." in the Actions pane.
In the "Advanced Settings" dialog, specify True for "Enable 32-Bit Applications".
Click OK to close the "Advanced Settings" dialog.
WScript.Echo is only valid for VBScript under WSH (i.e. scripts executed locally on the server via wscript.exe or cscript.exe). To debug in ASP, you may use Response.Write instead.
We have a functionality to add contacts to outlook.
I simply want to do it to existing outlook process if one is running or open if not running.
I get error:
Retrieving the COM class factory for component with CLSID
{0006F03A-0000-0000-C000-000000000046} failed due to the following
error: 80080005 Server execution failed (Exception from HRESULT:
0x80080005 (CO_E_SERVER_EXEC_FAILURE)).in case the process in not
already running.
Note: the below method is called 2 times.
My code is:
Private Sub InitObject()
If (Process.GetProcessesByName("OUTLOOK").Count > 0) Then
objOutlook = DirectCast(Marshal.GetActiveObject("Outlook.Application"), Outlook.Application)
'If objOutlook Is Nothing Then
Else
objOutlook = New Outlook.Application()
End If
If objNamespace Is Nothing Then
objNamespace = objOutlook.GetNamespace("MAPI")
objNamespace.Logon("", "", False, False)
End If
If objFolder Is Nothing Then
objFolder = objNamespace.GetDefaultFolder(10)
End If
End Sub
I read several posts on this saying admin privileges and all. Now I am running Visual Studio without Admin rights. I am sacred is this error will be seen in production too where we don't use Visual Studio?
What Outlook version do you have installed on the problematic PC? Is it the Click2Run edition of Outlook 2010?
Anyway, I see two possible causes for that:
You have got the Click2Run edition of Office 2010 installed on the PC. The fact is that the Click2Run edition of Office 2010 doesn't support automation. See Office 2010 Click-to-Run compatibility with add-ins for more information. Also you may find the How to: Verify Whether Outlook Is a Click-to-Run Application on a Computer article.
Your program and MS Outlook must both be run as administrator or as normal privilege level. They should be under the same privileges. You may find the How to self-elevate an application to a high privilege level under UAC article helpful.
Be aware, Outlook is a singleton. I.e. if it is already running, you will get a pointer to the already running instance when you create a new Outlook Application instance.
My application, originally created in win XP using vb6, stores program specific values in the registry. One of those values is where the database the program uses is located. The user can put it where ever they like and the program starts it prime the db location screen with the values last saved from the registry. This form uses the DriveListBox, DirListBox, and the FileListBox components. When running this application on Win 7, i am getting an error trying to set the dir list to the value stored in the registry which is a network drive. This all work fine if the drive the db is stored on is local.
The code is:
On Error GoTo HandleError
dbLocation = GetSetting(App.Title, "Settings", "DBLocation", dbserver)
If dbLocation = dbserver Then
Dir1.Path = GetSetting(App.Title, "Database", "ServerDBPath", "C:\") <----- fails
Else
Dir1.Path = GetSetting(App.Title, "Database", "LocalDBPath", "C:\")
End If
Drive1.Drive = Dir1.Path
Exit Sub
HandleError:
MsgBox "Error connecting to the network. Check network connections and try again.", vbOKOnly, "Connection error"
Drive1.Drive = "C:\"
I am suspecting the problem is with the directory list box. If i remove my error handling, the error thrown is "Device Unavailabe"
Any ideas on what happening? Are the components I am using not valid for win 7? For this application, the database has to be on a network drive so it is accessable from several PCs running the program. All of the PCs are running on Windows 7.
The drive, directory and file controls that come with VB6 are hopelessly out of date. They have not significantly changed since VB3 - and that was back in the mid nineties. These were designed for use with Windows 3.1! You would be better off using the Open File and Save File dialogues which come with the Common Dialogues library.
As for the dlls for vb6 provided in windows 7, see http://msdn.microsoft.com/en-us/vstudio/ms788708.aspx
GetSetting is a VB6 call to the registry. Windows 7 on a 64bit machine moved the location of the registry for 32bit apps to something like WOW3264.