[Solved] Set Recipient in cc in macro

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
DCTN54
Posts: 10
Joined: Wed May 10, 2023 9:27 am

[Solved] Set Recipient in cc in macro

Post by DCTN54 »

Hello,
I'm using a macro I found on this forum to send email from LibreOffice :

Code: Select all

Dim eMailAddress as String
Dim eSubject as String
Dim eMailer as Object
Dim eMailClient as Object
Dim eMessage as Object

 	eMailAddress = "toto@titi.fr"
 	eSubject = "test"
	eMailer = createUnoService("com.sun.star.system.SimpleSystemMail")
	     
		eMailClient = eMailer.querySimpleMailClient()     
		eMessage = eMailClient.createSimpleMailMessage()
		eMessage.setRecipient(eMailAddress)
		eMessage.setSubject(eSubject)
		eMessage.setAttachement (Array("C:\Users\toto\titi.doc"))
		eMessage.body="Ça marche?"
		
	eMailClient.sendSimpleMailMessage( eMessage, 0 ) 
My question is simple but I couldn't find the answer : how do I set recipient in cc or cci with this syntax ?
I tried different things but coudn't solve it.
Thanks for your answers.
Last edited by robleyd on Wed May 10, 2023 1:45 pm, edited 1 time in total.
Reason: Tagged [Solved]. Add green tick
LibreOffice 5.4.7.2.M6 on Windows 10
User avatar
Hagar Delest
Moderator
Posts: 32658
Joined: Sun Oct 07, 2007 9:07 pm
Location: France

Re: Set Recipient in cc in macro

Post by Hagar Delest »

Hi and welcome to the forum!

A quick search in the forum gave me several posts. In one of them, I found .setCcRecipient that could work.

Please add [Solved] at the beginning of the title in your first post (top of the topic) with the 🖉 button if your issue has been fixed.
LibreOffice 7.6.2.1 on Xubuntu 23.10 and 7.6.4.1 portable on Windows 10
DCTN54
Posts: 10
Joined: Wed May 10, 2023 9:27 am

Re: Set Recipient in cc in macro

Post by DCTN54 »

Merci pour ta réponse thanks for your answer but it didn't work here : undefined variable
Did I miss something ?

Code: Select all

Dim eMailAddress as String
Dim eMailCc as String
Dim eSubject as String
Dim eMailer as Object
Dim eMailClient as Object
Dim eMessage as Object

 	eMailAddress = "toto@titi.fr"
        eMailCc = "titi@toto.fr"
 	eSubject = "test"
	eMailer = createUnoService("com.sun.star.system.SimpleSystemMail")
	     
		eMailClient = eMailer.querySimpleMailClient()     
		eMessage = eMailClient.createSimpleMailMessage()
		eMessage.setRecipient(eMailAddress)
                eMessage.setCcRecipient(eMailCc)
		eMessage.setSubject(eSubject)
		eMessage.setAttachement (Array("C:\Users\toto\titi.doc"))
		eMessage.body="Ça marche?"
		
	eMailClient.sendSimpleMailMessage( eMessage, 0 ) 
LibreOffice 5.4.7.2.M6 on Windows 10
User avatar
Hagar Delest
Moderator
Posts: 32658
Joined: Sun Oct 07, 2007 9:07 pm
Location: France

Re: Set Recipient in cc in macro

Post by Hagar Delest »

Don't know, it was a very quick search.
More information in: [Solved] Emailing a group and [Solved] Send email with Subject & Body text.
LibreOffice 7.6.2.1 on Xubuntu 23.10 and 7.6.4.1 portable on Windows 10
DCTN54
Posts: 10
Joined: Wed May 10, 2023 9:27 am

Re: Set Recipient in cc in macro

Post by DCTN54 »

Okay, thanks anyway.
Finally I found out why it was not working : while setRecipient() needs a string as argument, setCcRecipient() needs an array.
In the code posted above, I replaced :
eMessage.setCcRecipient(eMailCc)
by :
eMessage.setCcRecipient(array(eMailCc))
and finally I get my email to be sent with cc.
LibreOffice 5.4.7.2.M6 on Windows 10
DCTN54
Posts: 10
Joined: Wed May 10, 2023 9:27 am

Re: Set Recipient in cc in macro

Post by DCTN54 »

How do I turn this topic to solved from here ?
LibreOffice 5.4.7.2.M6 on Windows 10
User avatar
Hagar Delest
Moderator
Posts: 32658
Joined: Sun Oct 07, 2007 9:07 pm
Location: France

Re: Set Recipient in cc in macro

Post by Hagar Delest »

Hagar Delest wrote: Wed May 10, 2023 10:54 am Please add [Solved] at the beginning of the title in your first post (top of the topic) with the 🖉 button if your issue has been fixed.
Done by a moderator.
LibreOffice 7.6.2.1 on Xubuntu 23.10 and 7.6.4.1 portable on Windows 10
Post Reply