You are viewing a plain text version of this content. The canonical link for it is here.
Posted to api@openoffice.apache.org by Peter Eberlein <pe...@refofd.verwalt-berlin.de> on 2013/12/18 09:57:25 UTC

css.system.XMailMessage vs. css.mail.XMailMessage

Hi,

first thanks to Ariel who simplified the system mail stuff.
But this seems not suitable for html 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("test@test.com"),Array("test@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.

Regards

Peter

---------------------------------------------------------------------
To unsubscribe, e-mail: api-unsubscribe@openoffice.apache.org
For additional commands, e-mail: api-help@openoffice.apache.org


Re: css.system.XMailMessage vs. css.mail.XMailMessage

Posted by Peter Eberlein <pe...@refofd.verwalt-berlin.de>.
Hi Ariel,
Am 18.12.2013 18:57, schrieb Ariel Constenla-Haile:
> 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("test@test.com"),Array("test@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).
>
Very cool stuff, thank you once again.

Regards

Peter

---------------------------------------------------------------------
To unsubscribe, e-mail: api-unsubscribe@openoffice.apache.org
For additional commands, e-mail: api-help@openoffice.apache.org


Re: css.system.XMailMessage vs. css.mail.XMailMessage

Posted by Ariel Constenla-Haile <ar...@apache.org>.
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("test@test.com"),Array("test@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