cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with Outlook 2016 and TC12

Contributor

Problem with Outlook 2016 and TC12

Hi,

 

I have a problem with Outlook 2016. I want to get the Ole Object of Outlook with this method :

 

 

language javascript

var msOutlook = Sys.OleObject("Outlook.Application");

 

But Testcomplete send me an error message when outlook is running : Failed to run server, CLSID {0006F03A-0000-0000-C000-000000000046}.

 

If outlook is not running, then the code works fine, but outlook don't receive message, until it is open manually.

 

In TC10, I get the Ole Object no matter the state of outlook (running or not).

 

Have you a solution ?

12 REPLIES 12
Frequent Contributor

Re: Problem with Outlook 2016 and TC12

This is because  Outlook can only run one session at a time. The better approach would be to test first for an existing Outlook process running and hook into it if it is running ; If the process is not running then create an Outlook session. Hope this might help.

Contributor

Re: Problem with Outlook 2016 and TC12

Outlook MUST be running. (in order to receive mail in real time).

 

Why I don't have this problem on TC10 ? Or maybe is the version of Outlook (2016 for the computer with TC12 and 2013 for TC10 ).

New Contributor

Re: Problem with Outlook 2016 and TC12

Hi,

 

I am having the same problem. I think it has to do with the Outlook version. It has been failing on me since moving to Windows 10 and Outlook 2016.

 

Eykxas, did you have Outlook 2016 working at one time with TC10?

 

Thank you.

 

Kind regards

Contributor

Re: Problem with Outlook 2016 and TC12

No. But I've found a workaround with this code :

 

function outlook_checkTC12(myInbox, folder, messageBody, subject){
	var inbox, i;

	var msOutlook = Sys.OleObject("Outlook.Application");

	var mapi = msOutlook.GetNamespace("MAPI");
	mapi.Logon("Outlook","password",false,true);
	mapi.SendAndReceive(false);
	Delay(10000);
	var found = false;


	if(myInbox==undefined) myInbox = get_inbox_outlook();
	if(folder==undefined) folder = "Boîte de réception";

	var inbox = mapi.Folders(myInbox).Folders(folder);
	Log.Message(inbox.Items.Count + " e-mails");

	for (i = 1; i <= inbox.Items.Count; i++)
	{
		toolEmail = inbox.Items.Item(i);
		body = toolEmail.Body;
		subject = toolEmail.Subject;

		if (body.indexOf(messageBody) != -1 && subject.indexOf(subject) != -1)
		{
			Log.Message(toolEmail.Body + "And " + toolEmail.Subject);
			Log.Message("The body and subject of the mail are verified");

			Log.Message("Number of attachments: " + toolEmail.Attachments.Count);

			//Attachments
			for(j = 1;j<=toolEmail.Attachments.Count;j++){
				Log.Message("Name of attachments"+j+" : " + toolEmail.Attachments(j).FileName);
			}
			//toolEmail.Delete();
			found=true;
			break;
		} 
		else 
		{
			continue;
		}
	}

	if(!found){
		Log.Error("The body and subject of the mail are not found");
	}

	msOutlook.Quit();
}
New Contributor

Re: Problem with Outlook 2016 and TC12

Hi Eykxas,

 

Thanks for the update!

This totally works for me again now.

 

Thanks a lot and a great weekend!

 

 

Contributor

Re: Problem with Outlook 2016 and TC12

I have the same problem but the code work around does not work for me. The error occurson the line:

var msOutlook = Sys.OleObject("Outlook.Application");

Contributor

Re: Problem with Outlook 2016 and TC12

Additionally this only errors at this point if Outlook is already open. So can i check to see if it is already open and skip this line and continue? If so what do I check for?

Contributor

Re: Problem with Outlook 2016 and TC12

With TC12 and Outlook 2016, TC12 can't access to Outlook if it's open. So I don't have a solution to keep outlook opened.

New Contributor

Re: Problem with Outlook 2016 and TC12

Yeah this is true.

 

Before Outlok 2016 I could keep outlook open. Now it needs to be closed when running the test. For me this is not an issue. But I could see situations where this might be a problem in a certian scenario. So no sollution for that one yet.

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