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
fwiw, i gave up on mapi and use ole for outlook instead. it has worked much better.
-mike