1. CJ Lai
  2. PowerBuilder
  3. Tuesday, 13 October 2020 15:15 PM UTC

Hi All

I would like to ask a question that somewhat relates to this one -> https://bit.ly/3j3rrFT

When I issue the command ConnectToNewObject('Outlook.Application'), Powerbuilder returns -3 => Object could not be created.

Later I found out that when I have an instance of Outlook running on my desktop, where the PB app also runs, the call returns the error code.

However, when there is no Outlook instance running, the app goes pass the call. Then, a process of setting up a new Outlook account commences as though it's a new computer.

 

What should I do to get around it?

Thanks

CJ

Accepted Answer
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Tuesday, 13 October 2020 17:02 PM UTC
  2. PowerBuilder
  3. # Permalink

Try and see if the same thing happens when you make an executable and run it.

In the past I've seen this behaviour come and go. My guess is that MS is doing updates which fix/break it.

Lately it works for me for both running from the IDE and from executable, but there's been a long time it only worked correctly from the EXE. All of this without doing any code changes. 

Comment
  1. Miguel Leeuwe
  2. Tuesday, 13 October 2020 23:40 PM UTC
It's MS ..

Glad it's solved for you now!
  1. Helpful
  1. Miguel Leeuwe
  2. Tuesday, 13 October 2020 23:44 PM UTC
Also, make sure your anti virus is up to date with it's definitions. Outlook does some kind of checks on that.

One of the things you will experience is the annoying dialog popping up saying " a program is trying to send email ... allow for 10 minutes " or something like that.
  1. Helpful
  1. Miguel Leeuwe
  2. Tuesday, 13 October 2020 23:52 PM UTC
One last thing: make sure the user has assigned a "Default Profile" in outlook (there must be a checkbox somewhere to make the choice the default, when you select a profile when using Outlook for the first time).

regards
  1. Helpful
There are no comments made yet.
mike S Accepted Answer Pending Moderation
  1. Tuesday, 13 October 2020 15:27 PM UTC
  2. PowerBuilder
  3. # 1

try connecttoobject, then newobject:

 

iole_outlook = create OLEObject
li_session = iole_outlook.ConnectToObject("","outlook.application")
IF li_session <> 0 THEN
    li_session = iole_outlook.ConnectToNewObject("outlook.application")
    If li_session <> 0 Then
        //"Error: Creating new Outlook session "
         destroy iole_outlook
         return -1
     end if
END IF

...

 

Comment
  1. mike S
  2. Tuesday, 13 October 2020 16:14 PM UTC
how was outlook started the first time? by your app?



  1. Helpful
  1. CJ Lai
  2. Tuesday, 13 October 2020 16:41 PM UTC
When there isn't an Outlook instance running already, my app failed at ConnectToObject (returns -5) and Then passed ConnectToNewObject (returns 0) and it goes on the setup process.

  1. Helpful
  1. CJ Lai
  2. Tuesday, 13 October 2020 19:20 PM UTC
Per Miguel's suggestion, your example code works in EXE although it doesn't in IDE.

Thank you, mike S, for your help.



CJ
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.