[Solved] Basic Macro to send email

Keyboard macros or custom scripts

[Solved] Basic Macro to send email

Postby Nelomf » Wed Nov 06, 2019 4:36 pm

Hello

I'm new with openoffice and i'm trying to send one active Calc file to Thunderbird as attachment

the code i have wrote is the following:
Code: Select all   Expand viewCollapse view
     Dim Path As String
     Dim thund As String
     Dim email As String
     Dim subj As String
     Dim body As String

     email = "my email"
     subj = "Teste"
     body = "Teste envio"
     Path = "D:\Compras\Encomendas 2020.ods"

     thund = "C:\Program Files (x86)\Mozilla Thunderbird\thunderbird.exe " & _
             "-compose " & """" & _
             "to='" & email & "'," & _
             "cc='" & cc & "'," & _
             "bcc='" & bcc & "'," & _
             "subject='" & subj & "'," & _
             "body='" & body & "'" & """"
           
   
  If Path = "" Then 'no attachment
                'do nothing

             Else 'with attachment
                thund = thund & ",attachment=" & Path
                End If

     Call Shell(thund, vbNormalFocus)


All works fine except the attachment.
This macro is linked to a push button on my sheet.

Tks for the help
Manuel
Last edited by Hagar Delest on Tue Nov 12, 2019 12:37 pm, edited 2 times in total.
Reason: tagged solved
Openoffice 4, Windows 7
Nelomf
 
Posts: 2
Joined: Wed Nov 06, 2019 4:29 pm

Re: Basic Macro to send email

Postby Zizi64 » Wed Nov 06, 2019 10:44 pm

Some similar code works for me in my Libreoffice with the Thunderbird E-mail client.

Code: Select all   Expand viewCollapse view
REM  *****  BASIC  *****

Sub send_email(sAttachmentURL as string, sEmailAddress as string, sSubject as string, sMessageBody as string)

Dim eMailer as Object
Dim eMailClient as Object
Dim eMessage as Object
   
   eMailer = createUnoService( "com.sun.star.system.SimpleSystemMail" )
   eMailClient = eMailer.querySimpleMailClient()     
   eMessage = eMailClient.createSimpleMailMessage()   
      eMessage.setRecipient(sMailAddress)
      eMessage.setSubject(sSubject)
      eMessage.setAttachement (Array(sAttachmentURL))
      eMessage.body = sMessageBody

   eMailClient.sendSimpleMailMessage( eMessage, 0 ) 'if you want to handle the sending manually in the mail client software
'   eMailClient.sendSimpleMailMessage ( eMessage,com.sun.star.system.SimpleMailClientFlags.NO_USER_INTERFACE ) 'Silent sending
End Sub
Tibor Kovacs, Hungary; LO6.1.6 on Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-6.3.3; AOO4.1.6
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
User avatar
Zizi64
Volunteer
 
Posts: 8538
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Basic Macro to send email

Postby Bidouille » Sun Nov 10, 2019 2:30 pm

Useless to have an external program like Thunderbird to do this.
AOO provide a dedicated service with com.sun.star.system.SystemMailProvider
User avatar
Bidouille
Volunteer
 
Posts: 294
Joined: Mon Nov 19, 2007 10:58 am
Location: France

Re: Basic Macro to send email

Postby Nelomf » Mon Nov 11, 2019 12:52 pm

Bidouille wrote:Useless to have an external program like Thunderbird to do this.
AOO provide a dedicated service with com.sun.star.system.SystemMailProvider

Tks
I follow the link and i got the solution in one of the posts.
Openoffice 4, Windows 7
Nelomf
 
Posts: 2
Joined: Wed Nov 06, 2019 4:29 pm


Return to OpenOffice Basic, Python, BeanShell, JavaScript

Who is online

Users browsing this forum: No registered users and 4 guests