1. André Rust
  2. PowerBuilder
  3. Friday, 27 January 2023 08:25 AM UTC

Hi,

I have a problem with outlook.
I use the free code Outlook from Topwiz.

If I use this it works perfekt, if the outlook is open. But if not the mails are in the Outbox and doesn't not send. 

...
lole_recipient = lole_mailitem.Recipients.Add( trim( sle_email1.text ) )
lole_recipient.Type = oleApplication.olTo
lole_recipient.Resolve
lole_mailitem.Display
lole_mailitem.Send
...


What can I do without open Outlook separately?

André

Outlook

This program is an example of OLE Automation of Microsoft Outlook. It will read a list of items from the Inbox and show them in a DataWindow. The currently selected item is shown in a webbrowser control.

The Outlook Object Model Reference contains details on all the Outlook objects, methods and properties.

André Rust Accepted Answer Pending Moderation
  1. Monday, 30 January 2023 08:56 AM UTC
  2. PowerBuilder
  3. # 1

Hi

other idea from me:

 

...
try
oleNameSpace = oleApplication.GetNameSpace( 'MAPI' )
oleNameSpace.isalive( )

lole_mailitem = oleApplication.CreateItem( oleApplication.olMailItem )
lole_mailitem.Subject = 'WWT Useranlage'
lole_mailitem.BodyFormat = oleApplication.olFormatHTML

ls_mail_text = '<p><strong><span style="font-family: Calibri, sans-serif;">Your Account;</span></strong></p>'+&
'<p><span style="font-family: Calibri, sans-serif;">User:</span></p>'+&
'<p><span style="font-family: Calibri, sans-serif;">Passwort:</span></p>'+&

lole_mailitem.HTMLBody = '<HTML><BODY>' + ls_mail_text + ' </BODY></HTML>'

lole_recipient = lole_mailitem.Recipients.Add( trim( mail1.text ) )
lole_recipient.Type = oleApplication.olTo
lole_recipient.Resolve
lole_recipient = oleNameSpace.syncObjects.item(1)
lole_recipient.start

lole_mailitem.Display
lole_mailitem.Send
catch (RuntimeError er2)
MessageBox( 'Fehler', 'Outlook error~r~n~r~n' + er2.text )
end try

??

Is there a function to check the outbox or draft for items 

then I can wait until empty befor close

??

oleApplication.DisconnectObject()
...

 

André

Comment
  1. André Rust
  2. Monday, 30 January 2023 13:26 PM UTC
Hi Miguel,

thats it. Send before start and no no display. Thx



...

lole_recipient = lole_mailitem.recipients.add( trim( tab_benutzer.tabpage_benutzer.sle_email1.text ) )

lole_recipient.type = oleapplication.olto

lole_recipient.resolve

lole_recipient = olenamespace.syncobjects.item(1)



lole_mailitem.send

lole_recipient.start



// lole_mailitem.display

catch (RuntimeError er2)

MessageBox( 'Fehler', 'Outlook konnte nicht gestartet werden~r~n~r~n' + er2.text )

end try



oleApplication.DisconnectObject()

if isvalid( oleApplication ) then destroy oleApplication

...
  1. Helpful
  1. Miguel Leeuwe
  2. Monday, 30 January 2023 17:13 PM UTC
yw,

haha, so you didn't really try the sample program that I made for you. No problem. As you might find, SyncObjects() - for at least during some time - gave us problems on Citrix connected users. The alternative is to use SendAndReceive(false). Probably SyncObjects is faster though, since SendAndReceive syncs each and every folder.

Glad it's working now, please mark as resolved.

regards.
  1. Helpful
  1. Miguel Leeuwe
  2. Monday, 30 January 2023 17:15 PM UTC
BTW: your call to "lole_recipient = olenamespace.syncobjects.item(1)" should also come AFTER the call to "Send" , but hey ... if it works .. it works!
  1. Helpful
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Sunday, 29 January 2023 18:51 PM UTC
  2. PowerBuilder
  3. # 2

Hi, André -

I hope Miguel's research and replies help you find a solution to your issue.

Since the problem seems to be an Outlook question and is not directly related to PB, have you tried searching Microsoft/Outlook forums or posting a non-PowerBuilder question on this topic on same?

Best regards, John

Comment
  1. André Rust
  2. Monday, 30 January 2023 06:36 AM UTC
Hi John,

not yet.



André
  1. Helpful
There are no comments made yet.
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Sunday, 29 January 2023 10:23 AM UTC
  2. PowerBuilder
  3. # 3

Hi,

First of all, I downloaded Roland's sample app and could not reproduce the problem. Even when disconnection and destroying the outlook ole objects (including the global one), immediatelty after the "send", everything just worked. Outlook does keep changing all the time (hopefully improving).

I KNOW I have had the same problem in the past. I didn't realize that we use the "SyncObjects" function only for early versions of Outlook. For later versions like 2013, 2016 and 365, we use "SendAndReceive(false)".

https://learn.microsoft.com/en-us/office/vba/api/outlook.namespace.sendandreceive Note: in the code, I've set the parameter to true as I was hoping to see a progress bar, but that probably only works if you have done the "display" of outlook. So just set it to false please.

For older versions of Outlook we use SyncObjects() https://learn.microsoft.com/en-us/office/vba/api/outlook.namespace.syncobjects 

See the attached sample app: You'll have to adjust the hardcoded email addresses and attachment filename. PB2019 R3.

Hopefully it solves you problem!

regards.

 

Attachments (1)
Comment
  1. André Rust
  2. Monday, 30 January 2023 06:41 AM UTC
Hi Miguel,

I write that Rolands Tool works perfect. What I only need is how can I do this with Outlook 365.



André
  1. Helpful
  1. Miguel Leeuwe
  2. Monday, 30 January 2023 07:06 AM UTC
Yes you say Roland's tool works "perfect", but describe the problem being it only works "perfect" when outlook is already open and the emails being stuck in the outbox until you manually open it.

My solution avoids you having to open outlook by the user.

Am I missing something here? Have you even tried it?

regards
  1. Helpful
  1. Miguel Leeuwe
  2. Monday, 30 January 2023 07:20 AM UTC
Maybe I should clarify that for me, Roland's sample works well, even if I don't have Outlook365 open.

I'm using Outlook365 32 bit version in case that might make a difference.
  1. Helpful
There are no comments made yet.
André Rust Accepted Answer Pending Moderation
  1. Saturday, 28 January 2023 17:20 PM UTC
  2. PowerBuilder
  3. # 4

Hi Miguel,

thanks for answer. 

I use PB 2019 R3 and office 365

I hope you can make a sample app for me and outlook send the mail without open outlook.

regards

André

Comment
  1. Miguel Leeuwe
  2. Saturday, 28 January 2023 18:27 PM UTC
Okay,

I'm running some backups but will try later and if not tomorrow.

Miguel
  1. Helpful
There are no comments made yet.
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Friday, 27 January 2023 08:30 AM UTC
  2. PowerBuilder
  3. # 5

Hi,

We solved this issue by "flushing" the outbox (using OLE). Have a look at https://community.appeon.com/index.php/qna/q-a/comment-on-bug-237-harry-schmidt-01-august-2017-ms-outlook-email-does-not-go-to-sent-folder 

I think it's the "SyncObjects" that does the trick.

regards,

MiguelL

Comment
  1. André Rust
  2. Friday, 27 January 2023 08:52 AM UTC
Hi Miguell,

this doesn't work. The mail is in the outbox and doeesn't send until I open the Outlook



André
  1. Helpful
  1. Miguel Leeuwe
  2. Friday, 27 January 2023 16:27 PM UTC
Hi André, I'll have a look this weekend and try to make a small sample app.

Which version of PB and which of Outlook ?

regards.
  1. Helpful
  1. André Rust
  2. Friday, 28 July 2023 08:47 AM UTC
Hi Miguel

I use PB 2019 R3 and Office 365



André
  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.