Date: prev next · Thread: first prev next last
2011 Archives by date, by thread · List index


Thanks to a friend, who can read the code behind thinks, our problem to use LO and the API to send Emails is solved, without using the clibboard content.

There is made use off the Mailmerge.py script who gives problems when sending non-ascii chararters like( éèàç tec...) but this script can easly been altered

In origin there is a line

"textbody = textbody.encode('utf-8')"

add a extra line

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

textbody = textbody.encode('utf-8')"

and you can send also non-ascii characters.

the code

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( "to@email.com", "from@email.com", "the subject", oTrans)

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>My 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 = "your.smtp.server.com"
        Case "Port"
            CurCont_GetValueByName = 25
        Case "ConnectionType"
            CurCont_GetValueByName = "Insecure"
    End Select
End Function

Function Authent_GetUserName() as Any
    Authent_GetUserName = "your_smtp_user"
End Function

Function Authent_GetPassword()
    Authent_GetPassword = "your_smtp_password"
End Function



--
Unsubscribe instructions: E-mail to discuss+help@documentfoundation.org
Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette
List archive: http://listarchives.documentfoundation.org/www/discuss/
All messages sent to this list will be publicly archived and cannot be deleted

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.