I have been using OpenOffice Calc on my Apple Macintosh computer for 12 years now. I do not use Microsoft Excel any more for basic coding.
I have enjoyed using the Built in Basic Command Language of OpenOffice to do most of the coding that I do. I do some Python coding, but not much.
There are many UnoServices that work under Ubuntu, LibreOffice, Window7 or 10, to send Emails with attachments such as:
eMailer = createUnoService ("com.sun.star.system.SimpleCommandMail")
eMailer = createUnoService( "com.sun.star.system.SimpleSystemMail" )
eMailer = createUnoService("com.sun.star.system.SystemMailProvider")
but
none of them work if you are using an Apple Mac. My question is, WHY NOT?
The only one that I have found that works without an attachment is launcher.executive
launcher = CreateUnoService("com.sun.star.system.SystemShellExecute")
The code looks something like this:
Code: Select all
Sub SimpleMailTo(eAddress as string, eSubject as string, eBody as string, CCeAddr as string, BCCeAddr as string)
Dim aHTMLanchor as string
Dim launcher as object
Dim eMessage as Object
launcher = CreateUnoService("com.sun.star.system.SystemShellExecute")
aHTMLanchor = "mailto:" & eAddress & "?cc=" & CCeAddr & "&&bcc=" & BCCeAddr & "&&subject=" _
& eSubject & "&&body=" & eBody
launcher.execute(aHTMLanchor, "", 0)
End Sub
Code: Select all
on run
delay 2
-- tell application id "com.apple.Mail"
-- set sendButton to localized string "ToolbarSend"
-- end tell
tell application "Mail"
set sendButton to localized string "ToolbarSend"
end tell
tell application "System Events" to tell process "Mail"
set frontmost to true
tell window 1
tell toolbar 1
click (first button whose description = sendButton)
delay 10
end tell
end tell
end tell
end run
The following code actually will attached a file, jump to the Apple Mail.app and display the message with the attachment. But all the other parts of the mail message like Mailto:, CC:, BC:, Subject: and Body: do not get passed across. No one seems to have finished the interface routines for the Mac Operating system.
Using: eMailer = createUnoService("com.sun.star.system.SystemMailProvider"), here is the code that attaches the file to the email but does nothing else.
Code: Select all
Sub openEmailClientTxt2(EmailAddr as string, SubjectTxt as string, BodyTxt as string, OpenWin as integer, AttchURL as string)
On Error GoTo ErrorHandle:
Dim eMailer as Object, eMailClient as Object, eMailMessage as Object
eMailer = createUnoService( "com.sun.star.system.SystemMailProvider" )
eMailClient = eMailer.queryMailClient
eMailMessage = eMailClient.createMailMessage()
eMailMessage.Recipient = EmailAddr
eMailMessage.Subject = SubjectTxt
eMailMessage.Body = BodyTxt
eMailMessage.Attachement = array(AttchURL)
eMailClient.sendMailMessage(eMailMessage,OpenWin)
' UI=OpenWin ' 0 = open email msg to edit, 1=send w/o opening.
' Some email program will require a confirmation window to open
' MailClient.sendSimpleMailMessage(MailMessage, UI)
Exit Sub
ErrorHandle:
msgbox "email could not be sent"
End Sub
So again, my question is WHY NOT???