cancel
Showing results for 
Search instead for 
Did you mean: 

Testcomplete 14 with Outlook 2016

SOLVED
mttsow
Occasional Contributor

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"); 

.

.

.

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
tphillips
Community Leader

Re: Testcomplete 14 with Outlook 2016

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.

 


--------------------
QA Systems Architect

View solution in original post

1 REPLY 1
tphillips
Community Leader

Re: Testcomplete 14 with Outlook 2016

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.

 


--------------------
QA Systems Architect

View solution in original post

New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors