Bug 135628 - SendSimpleMailMessage bodytext with new lines ends up as multiple recipients
Summary: SendSimpleMailMessage bodytext with new lines ends up as multiple recipients
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
5.2.7.2 release
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: Not Assigned
URL: https://bugzilla.mozilla.org/show_bug...
Whiteboard:
Keywords: bibisectRequest, regression
Depends on:
Blocks: Macro Thunderbird-Interoperability
  Show dependency treegraph
 
Reported: 2020-08-11 07:57 UTC by Zeke
Modified: 2024-07-10 08:25 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
Screenshot of output (81.88 KB, image/png)
2020-08-11 11:50 UTC, Zeke
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Zeke 2020-08-11 07:57:13 UTC
Description:
When sending email in a macro using sendSimpleMailMessage your bodytext can only have one row. If you have multiple rows divided with chr$(10) (new line) all rows ends up as additional recipents. 

LibreOffice 4.4.3.2 Base on Linux Mint 17.2 Mate 1.10.2 have not this problem.
LibreOffice 5.1.6.2 Base on Linux Mint 18.3 Mate 1.18.0 have not this problem.
LibreOffice 5.4.7.2 Base on Linux Mint 19.3 Cinnamon 4.4.8 have this problem.
LibreOffice 6.0.7.3 Base on Linux Mint 19.3 Cinnamon 4.4.8 have this problem.

Code:
	eMailer = createUnoService("com.sun.star.system.SimpleCommandMail")
	eMessage = eMailer.createSimpleMailMessage()
	eMessage.Recipient = eMailAdress
	eMessage.Subject=eSubject
	eMessage.Body=bodytext
	eMessage.Attachement=(Array(convertToUrl(filepath)))
	eMailer.sendSimpleMailMessage ( eMessage, _
	com.sun.star.system.SimpleMailClientFlags.NO_USER_INTERFACE )

System:

LO version 6.0.7.3

CPU threads: 8, OS: Linux 5.4, UI render: default, VCL: gtk3
Locale: sv-SE (en_US.UTF-8)
Linux Mint 19.3 Cinnamon 4.4.8

Steps to Reproduce:
1.Run the code above
2.
3.

Actual Results:
The mail client (tested thunderbird and evolution) opens up. If there is a chr$10 (new line) in the bodytext no rows are put into the bodytextfield. In the recipients field the original recipient is inserted and one recipient for every bodytext-row.

Expected Results:
Only one recipient and all rows of the bodytext in the bodytext field.


Reproducible: Always


User Profile Reset: No


OpenGL enabled: Yes

Additional Info:
-
Comment 1 Julien Nabet 2020-08-11 08:58:58 UTC
On pc Debian x86-64 with master sources updated today, I don't reproduce this.

I gave a try with:
Sub Main
	eMailer = createUnoService("com.sun.star.system.SimpleCommandMail")
	eMessage = eMailer.createSimpleMailMessage()
	eMessage.Recipient = "test@test.fr"
	eMessage.Subject="subject"
	eMessage.Body="body1"  + chr$(10) + "body2"  + chr$(10) + "body3"
	eMessage.Attachement=(Array(convertToUrl(filepath)))
	eMailer.sendSimpleMailMessage ( eMessage, _
	com.sun.star.system.SimpleMailClientFlags.NO_USER_INTERFACE )
End Sub

6.0 is an old branch.
Could you give a try to last stable LO version 6.4.5?
Comment 2 Zeke 2020-08-11 11:50:39 UTC
Created attachment 164153 [details]
Screenshot of output
Comment 3 Julien Nabet 2020-08-11 11:52:17 UTC
Thank you for your feedback.

Could you also attach the precise macro code you used?
Comment 4 Zeke 2020-08-11 11:58:30 UTC
The screenshot was with LO 6.4.5

code:

sub send_email(filepath as String, eMailAdress as String, yourOrderno as String)

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

	eSubject = "Delivery note your order " & yourOrderno

	eMailer = createUnoService("com.sun.star.system.SimpleCommandMail")
	eMessage = eMailer.createSimpleMailMessage()
	eMessage.Recipient = eMailAdress
	eMessage.Subject=eSubject
	eMessage.Body="Text1" & chr$(10) & "Text2" & chr$(10) & "Text3"
	eMessage.Attachement=(Array(convertToUrl(filepath)))
	eMailer.sendSimpleMailMessage ( eMessage, _
	com.sun.star.system.SimpleMailClientFlags.NO_USER_INTERFACE )

End sub
Comment 5 Julien Nabet 2020-08-11 12:07:32 UTC
I still don't reproduce the problem with your code (after having args of the function since LO complains I call the macro without args).
It seems I can't help here => uncc myself.
Since I don't have more questions, I'll put it back to UNCONFIRMED.
Comment 6 Zeke 2020-08-11 13:48:39 UTC
LO 5.1.6.2 seems to be the last version working.
LO 5.2.7.2 and onwards has this issue.
Comment 7 Zeke 2020-08-11 14:55:44 UTC
Tested with claws-mail instead of thunderbird and that was working with LO 6.4.5.

The issue seems to be between thunderbird and LO from version 5.2.7.2 and onwards.
Comment 8 Xisco Faulí 2021-02-09 15:12:12 UTC
Hello Zeke,
A new major release of LibreOffice is available since this bug was reported.
Could you please try to reproduce it with the latest version of LibreOffice
from https://www.libreoffice.org/download/libreoffice-fresh/ ?
I have set the bug's status to 'NEEDINFO'. Please change it back to
'UNCONFIRMED' if the bug is still present in the latest version.
Comment 9 Zeke 2021-02-15 07:06:21 UTC
New test with LO7.

New clean install of Linux Mint 20.1 Cinnamon.

sudo add-apt-repository ppa:libreoffice/ppa

Upgrade LO to latest fresh.

Assign an account to Thunderbird and test it so it can send email.

Run this code:

sub send_email(filepath as String, eMailAdress as String, yourOrderno as String)

Dim eSubject as String
Dim eMailer as Object
Dim eMailClient as Object
Dim eMessage as Object
Dim bodytxtstring as string

eSubject = "Delivery note your order " & yourOrderno
bodytxtstring="Please find delivery note attached" & chr$(10) & "as pdf." & chr$(10) & "Best Regards ..."

eMailer = createUnoService("com.sun.star.system.SimpleCommandMail")
eMessage = eMailer.createSimpleMailMessage()
eMessage.Recipient = eMailAdress
eMessage.Subject=eSubject
eMessage.Body=bodytxtstring
eMessage.Attachement=(Array(convertToUrl(filepath)))
eMailer.sendSimpleMailMessage ( eMessage, _
com.sun.star.system.SimpleMailClientFlags.NO_USER_INTERFACE )

end sub

Result in Thunderbird:

From: zxc@gmail.com
To: vbn@gmail.com
To: Please find delivery note attached
To: as pdf.
To: Best Regards ...
Subject: Delivery note your order 254456
Bodytext: (Nothing)

The bug seems to still be present in LO7.

Due to the bug we use the following code instead:

eSubject = "Delivery note " & deliveryID & " from your order no " & yourOrderno
shellstring="thunderbird -compose subject=" & eSubject & ",to=" & eMailAdress & ",message=/home/user1/Businessystem/txt/Deliveryconftxt,attachment='" & filepath & "'"
shell shellstring
Comment 10 pharmankur 2022-02-15 14:07:08 UTC
I am also having this EXACT problem with Libreoffice + Linux Mint + Thunderbird setting.

But it works well with evolution or Geary email client.


BTW Zeke, can you elaborate on your workaround code ?

--------------------
Due to the bug we use the following code instead:

eSubject = "Delivery note " & deliveryID & " from your order no " & yourOrderno
shellstring="thunderbird -compose subject=" & eSubject & ",to=" & eMailAdress & ",message=/home/user1/Businessystem/txt/Deliveryconftxt,attachment='" & filepath & "'"
shell shellstring
---------------------  

what exactly is this shellstring stuff ?
Comment 11 Zeke 2022-02-16 06:51:12 UTC
Explanation of the workaround we use as requested by Pharmankur:

eSubject = "Delivery note " & deliveryID & " from your order no " & yourOrderno
shellstring="thunderbird -compose subject=" & eSubject & ",to=" & eMailAdress & ",message=/home/user1/Businessystem/txt/Deliveryconftxt,attachment='" & filepath & "'"
shell shellstring

Shell execute a command at the cl (commandline)

Shellstring is a textstring with the command.

thunderbird starts thunderbird.
-compose tells thunderbird to initiate a mail to send.
subject= sets the mails subject.
to= sets the mails reciepent.
message= path to a textfil containing the bodytext of the mail.
attachment= path to a attachment file.
Comment 12 pharmankur 2022-02-16 10:06:23 UTC
Thank You Zeke for your quick response
That's a great workaround.
Thanks for sharing.
Comment 13 pharmankur 2022-02-16 12:52:00 UTC
Dear Zeke,
Based on your idea (of using shell script from libreoffice Macro) prepared a demo file.
It makes use of MUTT 

Details are here ---
https://forum.openoffice.org/en/forum/viewtopic.php?f=20&t=90100#p521622
Comment 14 dailyak77 2022-08-28 14:47:54 UTC Comment hidden (spam)
Comment 15 dailyak77 2023-01-05 04:09:47 UTC Comment hidden (spam)
Comment 16 Abdullah Sajid 2023-07-18 05:20:25 UTC Comment hidden (spam)
Comment 17 Zyen Malik 2023-09-29 11:49:49 UTC Comment hidden (spam)
Comment 18 Stéphane Guillou (stragu) 2023-10-18 19:37:44 UTC
Setting to new as per comment 10.
Version and regression keywords as per comment 6.
Comment 19 Stéphane Guillou (stragu) 2023-10-26 14:39:59 UTC
Is this the same issue as https://bugzilla.mozilla.org/show_bug.cgi?id=208230 ?
Which would make it "not our bug"?
Comment 20 pikashowpc 2023-11-14 07:03:47 UTC Comment hidden (spam)
Comment 21 pikashowpc 2023-11-14 07:09:41 UTC Comment hidden (spam)
Comment 22 Dolly Waelchi 2024-07-10 08:25:04 UTC
You must always have one recipient in the 'TO' field for the mass email to be sent. To accomplish this, just enter your own email address in that field.