Mailmerge macro

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
Peter_P
Posts: 2
Joined: Sat Feb 02, 2013 11:25 am

Mailmerge macro

Post by Peter_P »

Hello.

Maybe someone here can help me. I posted the same question in two other (national) communities. I didn't get an answer yet.

I want to run an email mailmerge through a macro. When I run it manually with the wizard, everything works fine. But when I run my macro, it always just uses the first record in the database and ignores all further records. When I change the macro to file-output instead of sending emails, the macro works just fine. I don't get it.

Here is my Code:

Code: Select all

Sub MailMergeService 
 Dim mm as Object 
 mm = CreateUnoService("com.sun.star.text.MailMerge") 
 With mm 
 'Output file 
 '   .OutputType = com.sun.star.text.MailMergeType.FILE 
 '   .OutputUrl = "file:///home/peter/" 
 '   .FileNamePrefix = "mm_" 
 '   .SaveAsSingleFile=True 
 'Output email 
    .DocumentURL = "file:///home/peter/ppt.odt" 'writer document url 
    .OutputType = 3 'email output
    .DataSourceName =  "testdb" 'database name 
    .CommandType = 1 '1 = predefined query, 2 SQL 
    .Command = "abc" 'query name
    .Subject = "testing subject" 
    .MailBody = "testing mailbody" 
    .AddressFromColumn = "email" 
 '   .BlindCopiesTo= Array("x@x.xx") 
    .SendAsAttachment = 1 
    .AttachmentName = "xtest.pdf" 
    .AttachmentFilter = "writer_pdf_Export" 
    .execute(Array()) 
    .dispose() 
 End With
 MsgBox "emails sent" 'message macro finished
 End Sub
please help

thanks
LibreOffice 4.0 RC2 on Ubuntu 12.04
Peter_P
Posts: 2
Joined: Sat Feb 02, 2013 11:25 am

Re: mailmerge macro

Post by Peter_P »

still no solution!
LibreOffice 4.0 RC2 on Ubuntu 12.04
User avatar
Villeroy
Volunteer
Posts: 31345
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: mailmerge macro

Post by Villeroy »

The best I can tell about the mail merge feature is that it works (mostly) without a single line of Basic code.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Post Reply