Email client, Windows10

I am stumped! Trying to set up emailing in a LO programme, and this line`

dim eMailer
dim eMailClient
eMailClient = eMailer.queryMailClient() returns ‘Object variable not set’ with both Outlook and Thunderbird tried as default emailer. I see from other queries that there can be issues with Outlook, but Thunderbird?

Why do you expect an empty variant variable (which is what appears with your dim eMailer) to have a queryMailClient method?

My apologies, I should have included the other bits above that including
eMailer = createUnoService("com.sun.star.system.SystemMailProvider")

I also do not see the ‘Tools>Options>Internet>Email’ link on my Windows system, just ‘Proxy’ and ‘MediaWiki’

There is no "SystemMailProvider" service in LibreOffice UNO API… Are you also hiding the fact that it’s maybe some daydreaming AI like ChatGPT that gave you such a code? :wink:

Indeed: it’s a non-Windows thing. On Windows, this configuration is fully automatic, using system-registered Simple MAPI mail client.

That, Sir, is an insult which in the old days would require a pistol duel at dawn :slight_smile:
It came from hours of trawling the internet and from this
https://www.openoffice.org/api/docs/common/ref/com/sun/star/system/module-ix.html
where it might appear to exist?

Ah - I see. AOO had introduced that unpublished interface somewhere in v.4.0; it had never been part of LibreOffice.

See SimpleSystemMail; also see _SendWithAttachment in access2base/DoCmd.

So, to cut a long story short, which uno service would you suggest I use?

If I use SimpleSystemMail I hit a basic runtime error with

eMailClient.sendMailMessage ( eMessage, com.sun.star.system.MailClientFlags.NO_USER_INTERFACE)

giving Property or method not found: MailClientFlags.

This is all taken from a multitude of forum mail queries. Is this covered in any books, eg Andrew’s?

Heh, you keep posting creative stuff, that simply cannot work,

  1. I already posted you the link to the detailed official API reference. On that, one could put the sendMailMessage to the Search box, and get to the respective page; on it, the method signature is defined:
void sendMailMessage ( [in] XMailMessage xMailMessage )	
              raises ( com::sun::star::io::NotConnectedException,
                       com::sun::star::mail::SendMailMessageFailedException,
                       com::sun::star::mail::MailException,
                       com::sun::star::datatransfer::UnsupportedFlavorException
                     )

The method only takes one argument. Wherever you could find samples telling otherwise - they are simply wrong, and having the API reference at hand, it’s odd to ignore it.

  1. On the same API reference page, one can put MailClientFlags to the Search box, and find out that LibreOffice does not have such an enumeration.

  2. And then - I also mentioned, that you may look at the access2base/DoCmd for a sample, how it is implemented in the AccessToBase library. It has a code that works both in AOO, and LO; and there, you might see that in AOO, all those SystemMailProvider and MailClientFlags exist, but in LO, SimpleSystemMail and SimpleMailClientFlags are used… (And XSimpleMailClient::sendSimpleMailMessage method does take the second argument.)

Hi,
I attach a sample demo Calc document demonstrating the use of emailing from within LibO using macros in BASIC.

FWIW & HTH the OP
test_email_v6.ods (42.5 KB)

3 Likes

Wow, impressive!

jfn - thanks for that, but it is way too advanced for my needs! I have now a working emailing routine using Andrew P’s ‘Outlook Attachment’ and for the info of anyone else who needs such, the outbound sending email is the default Outlook email.

Oddly, I’ve had a dabble with the MS Outlook properties and while ‘To’ and ‘Subject’ translate nicely via the OO bridge, `SendUsingAccount’ does not.