1. Christopher Craft
  2. PowerBuilder
  3. Wednesday, 29 April 2020 22:28 PM UTC

PB 2017 R3

I have come across an issue recently with customers complaining that when they process documents to email the email will just randomly stop working.  Without going into all the detail my Email object is designed to create a mail session, LogOn, set the parameters, Send the Email, LogOff and Destroy the object.  This has been this way for years. Now it seems the latest OS or Citrix, or... is having an issue. It seems the calls to LogOn and LogOff for every email is causing timing issues so it gets hung up.

The solution to this (I thought) was to simply create the MailSession object as a Shared Object and place the LogOn in the Constructor and the LogOff in the Destructor so they only execute once for the application. But what I am seeing is if the Mail client (Outlook in this case) is not currently running it will properly start it up and send the email but it still closes right after the Send! There is no LogOff going on anywhere else.  The object is correctly staying around until the app closes (I put in MessageBox's) so I am confused as to why the Send would always close the client?  I have also tried using NewMailSession for the LogOn thinking it needs its own pointer but it still closes after the send.

Any thoughts on this? I am needing to come up with a solution because the customer cannot upgrade their 2008 servers to 2016 with this issue.

Side Question: The above was using SimpleMAPI which starts up Outlook.exe. When I tried Extended MAPI I do not get OutLook.exe started but it sends email? What is happening there? I can't use Extended because of the bug where it gets stuck in the outbox.

Thanks!

Chris Craft

Accepted Answer
Christopher Craft Accepted Answer Pending Moderation
  1. Wednesday, 21 October 2020 23:31 PM UTC
  2. PowerBuilder
  3. # Permalink

The issue stemmed from Outlook being in Cache mode.  I also ended up creating s shared variable for the MAPI object so it stayed around for the duration of the application.

Chris Craft

Comment
  1. mike S
  2. Thursday, 22 October 2020 00:30 AM UTC
hey chris,

fwiw, i gave up on mapi and use ole for outlook instead. it has worked much better.

-mike
  1. Helpful
There are no comments made yet.
Christopher Craft Accepted Answer Pending Moderation
  1. Thursday, 30 April 2020 19:34 PM UTC
  2. PowerBuilder
  3. # 1

Thanks for your reply Miguel.  I don't seem to have the issue you explained. My logon works every time.  I just don't understand why the mail client shuts down after the Send. That is where I have an issue. I am going to post this as a Bug for Appeon to look at.l

Comment
  1. Miguel Leeuwe
  2. Friday, 1 May 2020 00:20 AM UTC
Yes, that's a great idea.

We have the logon problem only on "some" pc's at customers connected with Citrix. Since we don't configure the Citrix installations, lots of times, something is wrong on their site.

My code was just a suggestion for the outbox problem, to see if you could use extended Mapi and not having the problem of mail shutting down.

Mapi, outlook 365 and windows 10 are not always working so well: https://www.appeon.com/standardsupport/search/view?id=4163

regards
  1. Helpful
  1. Miguel Leeuwe
  2. Friday, 1 May 2020 00:22 AM UTC
A question: are your using Outlook 64 or 32 bits?

I think Mapi doesn't work that well with the 64 bits Outlook version
  1. Helpful
There are no comments made yet.
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Wednesday, 29 April 2020 23:42 PM UTC
  2. PowerBuilder
  3. # 2

By the way, we lately also had to put a "retry" around the logon, since it sometimes seems to fail. I think it's timeouts.

So we put the logon in a try catch, embedded in a loop to do 3 retries with a delay of 2 seconds.

regards

Comment
There are no comments made yet.
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Wednesday, 29 April 2020 23:38 PM UTC
  2. PowerBuilder
  3. # 3

Hi Christopher,

Not sure why this happens to you, but if you want to try extended MAPI, this is what we do to solve the "stuck in the Outbox" problem. It's the "SendAndReceive(false)" call.

This does use OLE and kind of makes you need to have MS Outlook, so in fact it takes away any reason to do the rest with MAPI. We now only use MAPI to pop up the Address book, since with MAPI it comes to the front and when using OLE and Outlook the Address book stays blinking in the task bar (most of the times). The rest we do it all with OLE. Also, we are thinking of a future better solution by using "Mailkit" for everything: https://github.com/jstedfast/MailKit

Meanwhile, this is what we do after the "send":

if gnv_app.ii_officeversion >= 14 then	
	if isValid(ioleNameSpace) then
		// u6 and v1, mjl, 13/08/19: put a try .. catch as it fails "sometimes" (especially with Outlook365, maybe because of caching settings):
		lb_retry = TRUE
		li_retryCount = 2
		do while lb_retry and li_retryCount > 0
			if li_retryCount = 1 then
				setpointer(hourglass!)
				sleep(2)
			end if
			try
				lb_retry = FALSE
				ioleNameSpace.SendAndReceive(false)
				Setpointer(Arrow!)
			catch ( RuntimeError  ortError1) // here I prefer the general RuntimeError above the more specific OLERuntimeError
				lb_retry = TRUE
				gnv_app.of_debug("SendAndReceive has failed, about to retry: " + ortError1.GetMessage())
			finally 
				li_retryCount --
			end try
		loop
		
	else
		
		if not isvalid(isafeioutlook_app) then // trident2, mjl, 29/09/15 since it isn't destroyed ...
			isafeioutlook_app = create oleobject
			isafeioutlook_app.ConnectToNewObject("outlook.application")
			try
				isafeioleNameSpace = isafeioutlook_app.GetNameSpace('MAPI')
				isafeioleNameSpace.Logon(gnv_app.is_defaultProfile, '', false, false) // trident2, 24/10/15, mjl: correct logon
			catch ( oleruntimeError oert5)
				gnv_app.of_debug("u_email.ue_sendMail() - oert5: " + oert5.getmessage())
			end try
		end if
		
		// u6 and v1, mjl, 13/08/19: put a try .. catch as it fails sometimes:
		lb_retry = TRUE
		li_retryCount = 2
		do while lb_retry and li_retryCount > 0
			if li_retryCount = 1 then
				setpointer(hourglass!)
				sleep(2)
			end if
			try
				lb_retry = FALSE
				isafeioleNameSpace.SendAndReceive(false)
				Setpointer(Arrow!)
			catch ( RuntimeError  ortError2) // here I prefer the general RuntimeError above the more specific OLERuntimeError
				lb_retry = TRUE
				gnv_app.of_debug("SendAndReceive has failed, retrying - ortError2: " + ortError2.GetMessage())
			finally 
				li_retryCount --
			end try
		loop
		
	end if
else	
	if isValid(ioleNameSpace) then
		try
			isafeioRecip = ioleNameSpace.SyncObjects.Item(1)
		catch (oleRuntimeError oert6)
			gnv_app.of_debug("SyncObjects has failed - oert6: " + oert6.GetMessage()) 
		end try
	else
		if not isvalid(isafeioutlook_app) then // trident2, mjl, 29/09/15 since it isn't destroyed ...
			isafeioutlook_app = create oleobject
			isafeioutlook_app.ConnectToNewObject("outlook.application")
			try 
				isafeioleNameSpace = isafeioutlook_app.GetNameSpace('MAPI')
				isafeioleNameSpace.Logon(gnv_app.is_defaultProfile, '', false, false) // trident2, 24/10/15, mjl: correct logon
			catch (OLERuntimeError oert)
				gnv_app.of_debug("u_email.ue_sendMail() - oert: " + oert.getmessage())
			end try 
		end if
		try 
			isafeioRecip = isafeioleNameSpace.SyncObjects.Item(1)
		catch(OLeRuntimeError oert2)
			gnv_app.of_debug("u_email.ue_sendMail() - oert2: " + oert2.getmessage())
		end try
		
	end if
	try
		isafeioRecip.Start
	catch (oleRuntimeError oert4)
		gnv_app.of_debug("u_email.ue_sendMail() - oert4: " + oert4.getmessage())
	end try
end if

 

 

Comment
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.