Hi Tomaz

 

Yes, that is exactly the problem I had, and the limit of 260K characters is 
consistent with my tests. I can get round it by saving the HTML to disk using 
the MailItem.SaveAs method, and then reading the file back from disk. I would 
try doing that with a memory disk, but I suspect the SaveAs method will not 
like writing to it. An alternative would be to use the MailItem.Body property, 
which only has the text of the message and so is much shorter. I would really 
need my own parser to read such a file, and I can’t load PetitParser or 
PetitParser2 into Pharo 8.

 

Presumably Pharo-Com should handle a long string more gracefully than just 
crashing the VM. But if these limits are intrinsic to COM in Windows, rather 
than Pharo-Com, there may be no way round it so it’s back to SaveAs.

 

Thanks for confirming that it’s not down to an error of mine.

 

Peter Kenny

 

From: Pharo-users <pharo-users-boun...@lists.pharo.org> On Behalf Of Tomaž Turk
Sent: 07 April 2020 21:27
To: Any question about pharo is welcome <pharo-users@lists.pharo.org>
Subject: Re: [Pharo-users] Automation of MS Office from Pharo

 

Thanks, Peter. I checked out the Outlook COM interface, noticed that the 
MailItem.HTMLBody property returns a string, which is implemented as BSTR in 
COM (more on this here: 
https://bytecomb.com/vba-internals-string-variables-and-pointers-in-depth/).

 

I tested the maximum lengths of strings with Word and my images crash under 
these circumstances:

- Pharo 8.0 64 bit when returning ByteString is longer than 16.379 characters

- Pharo 8.0 32 bit when returning ByteString is longer than 260.080 characters 
(approximately).

 

64 bit image crashes without any warning, however the 32 bit one crashes with

 



 

I presume this is the same behaviour as you report, Peter. I'm attaching the 
crash.dmp from 32 bit image. I believe that the crash happens when calling 
COMDispatchInstance>>propertyNamed: with the lengthy string to be returned.

 

Pablo, I hope you have some time to check this, my knowledge ends somewhere 
here ... :-| 

 

Thanks and best wishes,

Tomaz

 

 

 

 

 

Reply via email to