MAPI Error : The information store could not be opened. [MAPI 1.0 - [MAPI_E_LOGON_FAILED(80040111)]] [duplicate] - exchange-server

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.

Related

Start Outlook 2016 (64 Bit) automatically minimised to Windows 10 (64 Bit) system tray - No active Explorer object found

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.

ActiveX cannot create object on Set outA = CreateObject("Outlook.Application")

I have a legacy VB6 application to allow a user to send an email from the application itself.
Dim outA As Outlook.Application
Set outA = New Outlook.Application
If outA Is Nothing = True Then
'Outlook is not open... so need to create a new outlook
Set outA = CreateObject("Outlook.Application")
End If
In Windows 7 Office 2007 it works. User can have Outlook open and it works with no issues.
In Windows 10 Office 2016 this code does not work. It gives me an error on
Set outA = New Outlook.Application.
If Outlook is not open, the code works. I'm only getting this error if Outlook is open.
The error is...
ActiveX cannot create object error 429.
I have local privelages on my computer.
If I open my VB6 .exe explicitly as ADMIN and Outlook as ADMIN as well - the code gives me no issues.
I have UAC prompt disabled.
I cannot give ADMIN rights to user.
Am I missing a dll or something? I have a few more applications that have been used in Windows 7 and I have not had this issue.
Keep the early binding for development and once complete, scrap it for the late bind. Don't forget to remove the reference to Microsoft Outlook xx Object Library in VBE.
Early binding:
Dim outA As Outlook.Application
Set outA = New Outlook.Application
Late Binding:
Dim outA As Object
Set outA = CreateObject("Outlook.Application")
The reason is that early binding references a specific version of Outlook e.g. Microsoft Outlook 14.0 Object Library which is specific for Office 2010, so if it's not available it throws an error. The reference itself is marked with a "missing".
The late binding's CreateObject("Outlook.Application") takes care of that.
Repare office and ok (for me that was the solution)

WScript/CScript crashes when logging on using Outlook Redemption

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.

Outlook error Retrieving the COM class factory

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.

How can I programatically tell what Outlook addins are installed, and if they are enabled or not?

How do I determine what Outlook COM or PIA addins are installed, and if they are enabled or not.
How can I get this information, and hopefully the file version as well?
(1) If you want to access this information from inside another Outlook Add-in, you may use the the Application.ComAddins object (e.g. it's Count property gives you the number of add-ins installed). You can loop through this collection and check the LoadBehaviour property of the single COMAddin object to now if they're loading or if they're disabled.
(2) If you wand to access the information from outside of Outlook, you may consider to read the appropriate registry entries under the Software\Microsoft\Office\Outlook\Addins key.
(3) Please be aware that you cannot trust this information at all, because Office add-ins can be installed either for a single user or for all users. So you cannot access the installed add-ins absolutely, but only for the current user running your app /your procedure, by reading the abovementioned key (a) under HKLM and (b) under HKCU. The Application.COMAddins object shows you both information blended in one.
(4) I don't recall that a version number is available either in the COMAddin object or in the registry. To access that, you'll have to read the registry to find the file or assembly of the add-in, and access the file version. Please note that "old" COM Add-ins written in Visual Basic 6 or another language have other registry entries than VSTO add-ins or add-ins based on the Add-in Express tool.
To determine which installed add-ins are active (enabled/loaded):
'Loop through all installed add-ins and show whether they are active or not.
Dim app As New Outlook.Application
Dim name As String
Dim loaded As Boolean
For i = 1 To app.COMAddIns.Count
name = app.COMAddIns.Item(i).Description
loaded = app.COMAddIns.Item(i).Connect 'Returns True for active, False for inactive
MsgBox(name & ": " & loaded)
Next
To check the status of a specific add-in by name:
Dim app As New Outlook.Application
Dim addinName As String = "ADD-IN NAME"
Dim loaded As Boolean = app.COMAddIns.Item(addinName).Connect
MsgBox(addinName & ": " & loaded)
You can access that information even from outside of outlook.
Dim count As Integer
Dim app As New Outlook.Application
count = app.COMAddIns.Count
For i = 1 To count
MsgBox(app.COMAddIns.Item(0).Description)
Next

Resources