Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
e48a060e
Kaydet (Commit)
e48a060e
authored
Ock 15, 2013
tarafından
Caolán McNamara
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
make emailmerge work for me with python3
Change-Id: I4f79aa69b39d2be8fcceacc90b858f116f875385
üst
a5dc0463
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
10 deletions
+29
-10
mailmerge.README
scripting/source/pyprov/mailmerge.README
+18
-0
mailmerge.py
scripting/source/pyprov/mailmerge.py
+11
-10
No files found.
scripting/source/pyprov/mailmerge.README
0 → 100644
Dosyayı görüntüle @
e48a060e
Easiest way I find to test this is to...
1)
a) install fakemail and run it
b) tools->options->writer->mail merge email
c) localhost 8025
2)
a) type some text into writer that will exercise utf-8, e.g. "Caolán's test"
b) tools->mail merge wizard->next->email message->select address book
c) create, add one user with your own email address, ok
d) next, next, text, send merged document as email
e) and test all of plain text, html and the various attachment options
fake mail will dump the mail it gets into its pwd, if all that works, you can
then try with your own normal mail server.
scripting/source/pyprov/mailmerge.py
Dosyayı görüntüle @
e48a060e
...
...
@@ -36,6 +36,8 @@ from com.sun.star.mail import SendMailMessageFailedException
from
email.mime.base
import
MIMEBase
from
email.message
import
Message
from
email.charset
import
Charset
from
email.charset
import
QP
from
email.encoders
import
encode_base64
from
email.header
import
Header
from
email.mime.multipart
import
MIMEMultipart
...
...
@@ -152,7 +154,7 @@ class PyMailSMTPService(unohelper.Base, XSmtpService):
print
(
"PyMailSMTPService subject "
+
subject
,
file
=
dbgout
)
print
(
"PyMailSMTPService from "
+
sendername
,
file
=
dbgout
)
print
(
"PyMailSMTPService from "
+
sendermail
,
file
=
dbgout
)
print
(
"PyMailSMTPService send to
"
+
recipients
,
file
=
dbgout
)
print
(
"PyMailSMTPService send to
%
s"
%
(
recipients
,)
,
file
=
dbgout
)
attachments
=
xMailMessage
.
getAttachments
()
...
...
@@ -161,7 +163,7 @@ class PyMailSMTPService(unohelper.Base, XSmtpService):
content
=
xMailMessage
.
Body
flavors
=
content
.
getTransferDataFlavors
()
if
dbg
:
print
(
"PyMailSMTPService flavors len
"
+
len
(
flavors
),
file
=
dbgout
)
print
(
"PyMailSMTPService flavors len
%
d"
%
(
len
(
flavors
),
),
file
=
dbgout
)
#Use first flavor that's sane for an email body
for
flavor
in
flavors
:
...
...
@@ -169,11 +171,8 @@ class PyMailSMTPService(unohelper.Base, XSmtpService):
if
dbg
:
print
(
"PyMailSMTPService mimetype is "
+
flavor
.
MimeType
,
file
=
dbgout
)
textbody
=
content
.
getTransferData
(
flavor
)
try
:
textbody
=
textbody
.
value
except
:
pass
textbody
=
textbody
.
encode
(
'utf-8'
)
#http://stackoverflow.com/questions/9403265/how-do-i-use-python-3-2-email-module-to-send-unicode-messages-encoded-in-utf-8-w
textbody
=
textbody
.
encode
(
'utf-8'
)
.
decode
(
'iso8859-1'
)
if
len
(
textbody
):
mimeEncoding
=
re
.
sub
(
"charset=.*"
,
"charset=UTF-8"
,
flavor
.
MimeType
)
...
...
@@ -181,7 +180,9 @@ class PyMailSMTPService(unohelper.Base, XSmtpService):
mimeEncoding
=
mimeEncoding
+
"; charset=UTF-8"
textmsg
[
'Content-Type'
]
=
mimeEncoding
textmsg
[
'MIME-Version'
]
=
'1.0'
textmsg
.
set_payload
(
textbody
)
c
=
Charset
(
'utf-8'
)
c
.
body_encoding
=
QP
textmsg
.
set_payload
(
textbody
,
c
)
break
...
...
@@ -227,7 +228,7 @@ class PyMailSMTPService(unohelper.Base, XSmtpService):
maintype
,
subtype
=
ctype
.
split
(
'/'
,
1
)
msgattachment
=
MIMEBase
(
maintype
,
subtype
)
data
=
content
.
getTransferData
(
flavor
)
msgattachment
.
set_payload
(
data
)
msgattachment
.
set_payload
(
data
.
value
)
encode_base64
(
msgattachment
)
fname
=
attachment
.
ReadableName
try
:
...
...
@@ -250,7 +251,7 @@ class PyMailSMTPService(unohelper.Base, XSmtpService):
truerecipients
=
uniquer
.
keys
()
if
dbg
:
print
(
"PyMailSMTPService recipients are "
+
truerecipients
,
file
=
dbgout
)
print
(
(
"PyMailSMTPService recipients are "
,
truerecipients
)
,
file
=
dbgout
)
self
.
server
.
sendmail
(
sendermail
,
truerecipients
,
msg
.
as_string
())
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment