| View previous topic :: View next topic |
| Author |
Message |
Gonzalo Power User

Joined: 13 Apr 2004 Posts: 56
|
Posted: Fri Apr 23, 2004 5:34 am Post subject: Send an email from the API |
|
|
Hi, i would like to make a macro to send an email. I want the macro to open the mail client and send the mail. I'm using this code but this doesn't work at all. It can't create the SystemSimpleMail Service. If i use SimpleCommandMail i recieve a run time error too. Any idea? Thanks
' Example of how to send e-mail from Basic in OpenOffice.org.
Sub Main
' Your e-mail address goes here...
cEMailAddress = "me@somewhere.com"
cSubject = "Get generic Viagra online!!!"
' Use one of the following two lines, depending on which
' mailer you want to use.
' SimpleCommandMail will use your system's command line tools to send mail.
' SimpleSystemMail will use whatever (GUI) mail client you configured in
' Tools -> Options -> OpenOffice.org -> External Programs.
' For some reason the command line mail service does not appear to work on Windows?
'
' oMailer = createUnoService( "com.sun.star.system.SimpleCommandMail" )
oMailer = createUnoService( "com.sun.star.system.SimpleSystemMail" )
oMailClient = oMailer.querySimpleMailClient()
oMessage = oMailClient.createSimpleMailMessage()
oMessage.setRecipient( cEMailAddress )
oMessage.setSubject( cSubject )
'oMessage.setAttachment( .... )
' ...etc.
' The zero is the DEFAULTS constant from
' com.sun.star.system.SimpleMailClientFlags.
oMailClient.sendSimpleMailMessage( oMessage, o )
' One of the options in the SimpleMailClientFlags is an option
' to send the mail with no user interface. Just send it.
End Sub |
|
| Back to top |
|
 |
Cybb20 Super User


Joined: 02 Mar 2004 Posts: 1569 Location: Frankfurt, Germany
|
Posted: Fri Apr 23, 2004 6:11 am Post subject: |
|
|
Try this:
| Code: |
Sub SendEmail()
Dim eMailSystem
Dim omsg
eMailSystem=createUnoService( "com.sun.star.system.SimpleSystemMail" )
oMail = eMailSystem.querySimpleMailClient()
omsg = oMail.createsimplemailmessage()
With omsg
.setsubject("MySubject")
.setrecipient("dev@api.openoffice.org")' any adress
End With
oMail.sendSimpleMailMessage(omsg, com.sun.star.system.SimpleMailClientFlags.DEFAULTS)
End Sub
|
_________________ - Knowledge is Power - |
|
| Back to top |
|
 |
|