DrewJensen Super User


Joined: 06 Jul 2005 Posts: 2616 Location: Cumberland, MD
|
Posted: Sun Aug 27, 2006 3:47 pm Post subject: email via MailServiceProvider |
|
|
Two questions.
First - has anyone managed to get the "com.sun.star.mail.MailServiceProvider" services to work using OOBasic?
Second - My understanding is that there is a Python script that does work. Does anyone know where I can download a copy of that script?
Anyway - I have tried to use the code I found on the lists, with SMTP and Gmail. Follwoing is my test code. I blanked out the username and password - otherwise it is unchanged from my machine.
| Code: |
Sub MailService()
oMailProvider = CreateUNOService("com.sun.star.mail.MailServiceProvider")
oCont = CreateUNOListener("CurCont_","com.sun.star.uno.XCurrentContext")
oAuth = CreateUNOListener("Authent_","com.sun.star.mail.XAuthenticator")
oMailServer = oMailProvider.Create("com.sun.star.mail.SMTP")
oMailServer.Connect(oCont,oAuth)
msgbox xMailServer.isConnected
oMsg=CreateUnoService("com.sun.star.mail.MailMessage")
oMsg.Create("drewjensen.inbox@gmail.com", "andrew@paintedfrogceramics.com", "Hi from OOot", "Hello there - Me")
oMailServer.Disconnect()
End Sub
Function CurCont_GetValueByName(s) as Any
Select Case s
Case "ServerName"
CurCont_GetValueByName = "smtp.gmail.com"
Case "Port"
CurCont_GetValueByName = 465
Case "ConnectionType"
CurCont_GetValueByName = "SSL"
End Select
End Function
Function Authent_GetUserName() as Any
Authent_GetUserName = "xxxxxxxxxxxxx"
End Function
Function Authent_GetPassword()
Authent_GetPassword = "xxxxxxxxxx"
End Function
|
Using the latest developers build this code when run goes off for a good while, my firewatl pops up asking if I should let sofice.exe connect to the internet - I say yes, and finally it throws the following error
| Quote: |
BASIC runtime error
An exception orrurred
Type: com.sun.star.uno.RuntimeException
Message: socket.error:(10054,"Connection reset by peer'), trackback follows...( trace back into smtplib.py )
apparently this is handled in a python library within OOo.
|
Interestingly if I check the firewall logs I find this as the last entry after doing this:
| Quote: |
Application Hijacking has been detected
The application: C:\Program Files\OOo-dev 2.0\program\soffice.exe try to launch another application: C:\Program Files\OOo-dev 2.0\program\soffice.bin to go to remote host pop.gmail.com
|
Right now I am hoping someone can point me to that Python script that supposedly works.
Thanks
Drew |
|