Copies de seguretat per correu (OpenOffice.org)

Aquesta és una macro per a l’OpenOffice.org per a enviar documents per correu electrònic de manera “silenciosa”.


Sub SendMailBackup()
Dim MailAddress As String, MessageSubject As String
Dim ThisDocURL As String, DocDir As String, FileName As String
Dim MailAgent As Object, MailClient As Object, MailMessage As Object, ThisDoc As Object
Dim Args()
ThisDoc=ThisComponent
If ThisDoc.hasLocation=False Then
MsgBox "You must save the document first!" :End
End If
ThisDocURL=ThisDoc.getURL()
If ThisDoc.isModified Then
ThisDoc.storeAsURL(ThisDocURL, Args)
End if
If (Not GlobalScope.BasicLibraries.isLibraryLoaded("Tools")) Then
GlobalScope.BasicLibraries.LoadLibrary("Tools")
End If
DocDir=DirectoryNameoutofPath(ThisDocURL, GetPathSeparator())
FileName=Dir(ThisDocURL, 0)
MailAddress="backup@email.com"
MessageSubject="[OOO_DOC_BACKUP] ” & FileName & ” ” & CDateToISO(Date) & ” - ” &_
Hour(Time)& “:” & Minute(Time) & “:” & Second(Time)
If GetGUIType=1 Then
MailAgent=CreateUnoService(”com.sun.star.system.SimpleSystemMail”)
Else
MailAgent=CreateUnoService(”com.sun.star.system.SimpleCommandMail”)
End If
MailClient=MailAgent.querySimpleMailClient()
MailMessage=MailClient.createSimpleMailMessage()
MailMessage.setRecipient(MailAddress)
MailMessage.setSubject(MessageSubject)
MailMessage.setAttachement(Array(ThisDocURL))
MailClient.sendSimpleMailMessage(MailMessage, 1)
End Sub

Font: Linux.com - OooBasic crash course: One-click email backup of OpenOffice.org documents

2 Comments

  1. mark
    Posted 1/7/2008 at 2:57 pm | Permalink

    Hola, fa un parell de mesos que he provat l’OpenOffice.org i especialment en la part de macros, programació en oooBasic.
    Voldría comentar-te si questa macro de copies de seguretat per correu funciona amb windows Xp.
    em surt un error al executar-la.

    ‘Error del temps d’execució en Basic
    s’ha produït una excepció
    type: com.sun.star.uno.Exception
    Message: Send email failed’

    gracies

  2. Posted 6/7/2008 at 6:46 pm | Permalink

    Hola Mark,

    no tinc cap Windows Xp a mà per a provar-ho però en principi hauria de funcionar.

Post a Comment

Your email is never published nor shared.