Hi Peter,

On Wed, Dec 18, 2013 at 09:57:25AM +0100, Peter Eberlein wrote:
> Hi,
> 
> first thanks to Ariel who simplified the system mail stuff.
> But this seems not suitable for html body. 

It depends on the MUA implementation, but in general you can assume the
string is a plain text body.

> So I tried:
> 
> 'a selection in the textdocument must be done before
> xTransferable = ThisComponent.CurrentController.getTransferable()
> dataflavors = xTransferable.getTransferDataFlavors()
> data = dataflavors(2)'html
> transferData = xtransferable.getTransferData(data)
> 
> xMessage = 
> com.sun.star.mail.MailMessage.create(Array("t...@test.com"),Array("t...@test.com"),"Subject",
> xTransferable )
> 
> But this fails. Any ideas why? I think the xTransferable isn't the
> correct type, because it supports other mimetypes too.

Yes, this fails because the implementation only takes into account the
first data flavour, see
http://www.openoffice.org/api/docs/common/ref/com/sun/star/mail/XMailMessage.html#Body
"The body of the mail message. It is expected that the transferable
delivers the data as a string. Although a transferable may support
multiple data flavors only the first data flavor supplied will be used
to retrieve the data and it is expected that the data will be provided
as a string."

You can find some examples on
http://people.apache.org/~arielch/api/MailApiTest.zip (they might look
a little overcomplicated, because I used them to test some bug fixes).

Pay attention to MAIN.Test_Html_Body and
Body.MailBody_CreateFromCurrentDocument, the last one creates a UNO
listener depending on the mime type (plain text or HTML); then
HTMLTextBodyFromCurrentDoc_getTransferData calls
__GetTransferDataFromCurrentDocument to do the job:

- export the current document to HTML
- read the HTML document as a string (this has a big limitation in
  Basic, where strings are implemented internally with an old class that
  has a 64k limit for the string's content).


Regards
-- 
Ariel Constenla-Haile
La Plata, Argentina

Attachment: pgpCMXmh8gLci.pgp
Description: PGP signature

Reply via email to