Testcomplete 14 with Outlook 2016
Hi, I have this error:
TypeError: NamespaceMAPI.Folders is not a function
with testcomplete 14 with Outlook 2016 with the following script.
It worked in testcomplete12 with Outlook 2014.
Does anything have any suggestion?
Thanks in advance.
Mary
var OutlookApplication = Sys.OleObject("Outlook.Application");
var NamespaceMAPI = OutlookApplication.GetNamespace("MAPI");
if (NamespaceMAPI.Accounts.Item(accountName) != null)
{
NamespaceMAPI.SendAndReceive(false);
var inbox = NamespaceMAPI.Folders(accountName).Folders("Inbox");
.
.
.
The way we do this in our scripts is to use the mapiNamespace.Stores to find the account we're after:
var testEmailStore; for (var i = 0; i < mapiNamespace.Stores.Count; i++) { store = mapiNamespace.Stores.Item(i + 1); // Ignore case of DisplayName, it can be entered in differently if (store.DisplayName.toLowerCase() == ProjectSuite.Variables.testEmailDisplayName.toLowerCase()) { Log.Message("Found email store for '" + ProjectSuite.Variables.testEmailDisplayName + "'") testEmailStore = store; } }
We can then use testEmailStore to get the folders:
var inbox = testEmailStore.Folders("Inbox")
The whole Outlook OLE stuff is really annoying, there are so many ways to do one thing and most of the examples are in VB and are very old.