Ask Your Question

Macro to send email to a specific address [closed]

asked 2016-09-20 12:59:50 +0100

this post is marked as community wiki

This post is a wiki. Anyone with karma >75 is welcome to improve it.

I have this: dispatcher.executeDispatch(document, ".uno:SendMailDocAsPDF", "", 0, Array())

But I want to send email to an address (hard-coded), like this:

Here's the whole macro I have now:

sub Send_As_PDF
rem ----------------------------------------------------------------------
rem define variables
dim document   as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("")
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:SendMailDocAsPDF", "", 0, Array())
end sub

(Edited for better readability; Lupp)

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Alex Kemp
close date 2020-09-29 23:36:12.584888


I am afraid you won't get anywhere with this topic based on a recorded macro.
Did you already study 13.15.4 of "The Book" by Andrew Pitonyak, mainly the final Sub of the listing there? The book is availablel from this webpage. Also visit this page.
The MailMessage should also have a .Body property.

Lupp gravatar imageLupp ( 2016-09-20 14:36:24 +0100 )edit

I try to start with a recorded macro because I don't know about the object model. Often I can edit and tailor it to my needs afterward. But the book will be a huge help! Thanks very much.

LunixTheFirst gravatar imageLunixTheFirst ( 2016-09-20 22:24:07 +0100 )edit

1 Answer

Sort by » oldest newest most voted

answered 2017-04-18 15:48:35 +0100

librebel gravatar image

updated 2017-04-18 16:01:32 +0100

Hello dear fellow LibreOffice User, i don't know if it still matters at this time, but you could write:

Sub Send_As_PDF()
    Dim oFrame, oDispatch
    Dim aProps() As New
    AppendProperty( aProps(), "Recipient", "" )
    oFrame = ThisComponent.CurrentController.Frame
    oDispatch = createUnoService( "" )
    oDispatch.executeDispatch( oFrame, ".uno:SendMailDocAsPDF", "", 0, aProps() )
End Sub

Sub AppendProperty( oProps(), sName As String, ByVal oValue )
    Dim oProperty As New
    Dim iLB As Integer, iUB As Integer
    oProperty.Name = sName
    oProperty.Value = oValue
    iLB = LBound( oProps() )
    iUB = UBound( oProps() ) + 1
    ReDim Preserve oProps( iLB To iUB )
    oProps(iUB) = oProperty
End Sub
edit flag offensive delete link more

Question Tools

1 follower


Asked: 2016-09-20 12:59:50 +0100

Seen: 948 times

Last updated: Apr 18 '17