Bug 38713 (mailmerge.py) - Mailmerge Python script not working with multiple recipients
Summary: Mailmerge Python script not working with multiple recipients
Status: RESOLVED FIXED
Alias: mailmerge.py
Product: LibreOffice
Classification: Unclassified
Component: LibreOffice (show other bugs)
Version:
(earliest affected)
unspecified
Hardware: Other All
: medium normal
Assignee: Caolán McNamara
URL:
Whiteboard: target:3.7.0
Keywords:
Depends on:
Blocks:
 
Reported: 2011-06-27 05:50 UTC by Fernand
Modified: 2013-12-16 23:02 UTC (History)
0 users

See Also:
Crash report or crash signature:


Attachments
repaired PY file (14.48 KB, text/x-python)
2011-06-27 05:50 UTC, Fernand
Details
Patch for the change proposed by Fernand (528 bytes, patch)
2011-06-27 09:50 UTC, Simos Xenitellis
Details
Patch for the change proposed by Fernand (updated) (445 bytes, patch)
2011-06-27 09:57 UTC, Simos Xenitellis
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Fernand 2011-06-27 05:50:35 UTC
Created attachment 48468 [details]
repaired PY file

Found the repair my self:

at line 154  we have  textbody = textbody.encode('utf-8')

where the textbody contains non-ascii characters like (éèà etc...)

so just insert

textbody = unicode( textbody, "utf-8" )

before line 154 and everyting works fine !
Comment 1 Simos Xenitellis 2011-06-27 09:50:24 UTC
Created attachment 48471 [details]
Patch for the change proposed by Fernand

Do not apply this patch yet.

I am not sure whether it can catch all corner cases.
We need test cases to figure out what input encodings LibreOffice can feed to mailmerge.py.
Comment 2 Fernand 2011-06-27 09:56:41 UTC
Simos,
Maybe a wise decision, i tested a lot this afernoon, and rund (ones) is a error that "unicode decoding was not supported"
After restarting Libreoffice al worked  smootly again.
I tried contact the autor, maybe he can help us further
Comment 3 Simos Xenitellis 2011-06-27 09:57:33 UTC
Created attachment 48475 [details]
Patch for the change proposed by Fernand (updated)

Do not apply yet this patch.

The patch now reflects the changes that Fernand proposes.
Comment 4 Fernand 2011-07-11 06:40:22 UTC
Hallo, Symos

After some more testing i found a new problem with the Phyton script used witj the API and Basic

for creating a Emails message i use
oMailServiceObj = com.sun.star.mail.MailMessage
oMail = oMailServiceObj.create( "To1@pmg.be" , "From@pmg.be", "the subject", oTrans)

That works fine

but having multiple Recipients tTO adresses gives a error

so i make oMail with the first To adress
 then i uses the available Method for the oMail object "addRecipient(To2Adress)

then i have 2 problems:
using Xray to inspect oMail.recipients gives a error (index uot of range)
and when running the python script gives a error

the function msg['To'] = COMMASPACE.join(recipients)
recipients must be a string but a tuple is found ????

so i suppose that "addRecipient" is not making a proper Basic Array and endup also as a wrong type in Python.
please use this code to test:

Sub Main
oMailProvider = CreateUNOService("com.sun.star.mail.MailServiceProvider")
oCont = CreateUNOListener("CurCont_","com.sun.star.uno.XCurrentContext")
oAuth = CreateUNOListener("Authent_","com.sun.star.mail.XAuthenticator")
oTrans = CreateUNOListener("Trans_","com.sun.star.datatransfer.XTransferable")
oMailServiceObj = com.sun.star.mail.MailMessage
oMail = oMailServiceObj.create( "to1@pmg.be" , "from@pmg.be", "the subject", oTrans)

'xray omail
omail.addRecipient("to2@pmg.be")

'xray omail

xMailServer = oMailProvider.Create("com.sun.star.mail.SMTP")

xMailServer.Connect(oCont,oAuth)
xMailServer.SendMailMessage(oMail)
xMailServer.Disconnect()

End Sub



Function Trans_getTransferData(f) As Any
  
    if f.MimeType = "text/html" then
        Trans_getTransferData = "<html><body><p><B>My</B> Mail!</p></body></html>"
    end if
End Function

Function Trans_getTransferDataFlavors() As Variant
    Dim f As New com.sun.star.datatransfer.DataFlavor
    f.MimeType = "text/html"
    Trans_getTransferDataFlavors = Array(f)
End Function

Function Trans_isDataFlavorSupported(f) As Boolean
   Trans_isDataFlavorSupported = (f.MimeType = "text/html")
End Function


Function CurCont_GetValueByName(s) as Any
    Select Case s
        Case "ServerName"
            CurCont_GetValueByName = "mail.pmgroup.be"
        Case "Port"
            CurCont_GetValueByName = 25
        Case "ConnectionType"
            CurCont_GetValueByName = "Insecure"
    End Select
End Function

Function Authent_GetUserName() as Any
    Authent_GetUserName = "sos@pmgroup.be"
End Function

Function Authent_GetPassword()
    Authent_GetPassword = "mypassword"
End Function
Comment 5 Björn Michaelsen 2011-12-23 12:28:25 UTC
[This is an automated message.]
This bug was filed before the changes to Bugzilla on 2011-10-16. Thus it
started right out as NEW without ever being explicitly confirmed. The bug is
changed to state NEEDINFO for this reason. To move this bug from NEEDINFO back
to NEW please check if the bug still persists with the 3.5.0 beta1 or beta2 prereleases.
Details on how to test the 3.5.0 beta1 can be found at:
http://wiki.documentfoundation.org/QA/BugHunting_Session_3.5.0.-1

more detail on this bulk operation: http://nabble.documentfoundation.org/RFC-Operation-Spamzilla-tp3607474p3607474.html
Comment 6 Björn Michaelsen 2012-06-26 08:16:57 UTC
Is this patch improving things or is this patch obsolete?
Comment 7 Fernand 2012-06-29 01:03:47 UTC
tested stable 3.5
The non-asci characters are OK 
AddRecipient still not working
Comment 8 Caolán McNamara 2012-06-29 04:23:43 UTC
gotcha, wasn't concatenating tuples correctly :-)
Comment 9 Not Assigned 2012-06-29 04:26:24 UTC
Caolan McNamara committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=6843ce885e3e128d24ea8472da4883de223213cd

Resolves: fdo#38713 fix multiple recipients in mailmerge