rem --- This macro sends an Email directly from a LibreOffice Basic shell command.
rem --- This is run under the Twister OS after installing and
rem --- configuring the Mutt command line Email app.
rem --- The Mutt app is available for both Macs, PC and Linux based Computers.
rem --- I am now using the Mutt Email App on a Raspberry Pi 4 running Twister OS.
rem --- Developed by Al Forster, AVFConsulting LLC, Aug,2021
rem ----------------------------------------------------------------------
Code: Select all
sub SEmailshell
rem ----------------------------------------------------------------------
Dim TermProcLoc, BodyTxt, Subject, EMaddress, DocPath as string
Dim mut as string, mut1 as string, mut2 as string
rem ----------------------------------------------------------------------
TermProcLoc = chr(34) & "bash -c 'exo-open --launch TerminalEmulator "
BodyTxt= "please find file attached "
Subject= "Attachment test"
EMaddress = "Client1@gmail.com "
DocPath= "/home/pi/Desktop/Document/pdfgen-1.pdf"
rem ----------------------------------------------------------------------
mut1 = "echo " & chr(34) & BodyTxt & chr(34) & " | mutt -s " & chr(34) & Subject & chr(34) & " "
mut2 = EMaddress & " -a " & chr(34) & DocPath & Chr(34)
mut = mut1 & mut2
'msgbox "mut= " & mut
shell "bash -c 'exo-open --launch TerminalEmulator " & mut & "'" & Chr(34)
rem ----------------------------------------------------------------------
end sub
eMailer = createUnoService("com.sun.star.system.SimpleSystemMail")
When asking for the link to the Mail Client with the query command:
eMailClient = eMailer.querySimpleMailClient().
I have always gotten the Error Message: Error: Basic Runtime error: "Object Variable Not Set"
The problem is that this routine works when you are using Windows XP, 7 or 10. But if you are using an Apple Mac or Linux based computer, you get the error mentioned above. The Mail Client recommended is usually Thunderbird. Since I prefer using a Mac for developing code, I had to develop my own emailing routines which involved outputting Body ,Subject, EMailAddresses, DocPath (to file Attachments) to a file, then launching an AppleScript that would send out the document using the Apple Mail Client App. That was a long tedious process but I finally got it working flawlessly.
I started using the Raspberry PI 3b, a $35.00 computer about 4 years ago. I did not think it was fast enough then, but in the past year the Raspberry Pi 4b has arrived for about $45.00, fully configured with a 256gb SSD and Monitor for about $150. Anyway, configuring that with the Free, Open Source Twister OS, one can configure it to look like a Mac running Big Sur, or like a Windows 10 Computer. All you have to do is open a configuration menu and select a different "SKIN".
The bottom line is, with Twister OS and the Mutt Terminal based Email App installed and configured, I can send my clients stock analysis info using a OpenOffice Calc app I developed, regardless if it was run on a very expensive Mac, Windows PC or a fairly inexpensive Raspberry Pi 4b computer. I have included the intact Macro above because I have been frustrated over the past 8 years in not being able to get the Emailing code provided in this forum running on anything but Microsoft Windows based systems.