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

Re: [tdf-discuss] When can we have a API to send Emails ?


OK,

in the mean time i found some basic stuff who can do the job.
It looks ugly: but it works and the content is "formated as in the Writerdoc"

Copy the Body content from a opened Writerdoc, then use this content from the clpiboard to send the Email


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")

copydoccontentToClipboard

oClip = CreateUnoService("com.sun.star.datatransfer.clipboard.SystemClipboard")

oMailServiceObj = com.sun.star.mail.MailMessage
rem http://api.openoffice.org/docs/common/ref/com/sun/star/mail/MailMessage.html
rem Use the contents of the clipboard as the content of the email
oMail = oMailServiceObj.create( "sos@pmg.be", "sos@pmg.be", "SUBJECT",oClip.getContents())

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

xMailServer.Connect(oCont,oAuth)
msgbox xMailServer.isConnected

xMailServer.SendMailMessage(oMail)
xMailServer.Disconnect()

End Sub

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

sub copydoccontentToClipboard
dim document   as object
dim dispatcher as object
dim oDoc, oVC
oVC = ThisComponent.CurrentController.getViewCursor
oVC.gotostart(false)
oVC.gotoEND(true)
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
dispatcher.executeDispatch(ThisComponent.CurrentController.Frame, ".uno:Copy", "", 0, Array())
end sub


--
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.