Sending an email from Calc with a macro

Creating a macro - Writing a Script - Using the API

Sending an email from Calc with a macro

Postby Haese005 » Wed Mar 22, 2017 7:21 pm

Hi there,
Maybe I haven't searched enough in the database of this forum, but my problem is that I am looking for a simple macro script to send an email to 2 different email addresses from calc (see the attachment) .
My email client is Microsoft Outlook. My OpenOffice version is 4.1.3.
I must be able to put the subject in the email. That's all but I am an so called aliën in OpenOffice.
Can someone help me with this , please? ;)
I am from the Netherlands so that's why the language in this spreadsheet is probably strange for you
(16 KiB) Downloaded 22 times
OpenOffice 4.13 and Operating system: Windows 10
Email Client: Outlook
Posts: 4
Joined: Wed Mar 22, 2017 7:02 pm

Re: sending an email from calc with a macro

Postby FJCC » Wed Mar 22, 2017 8:49 pm

This works for me
Code: Select all   Expand viewCollapse view
Sub SendEmail
eMailAddress = ";"
eSubject = "Test Message"
eMailer = createUnoService("")

eMailClient = eMailer.queryMailClient()

eMessage = eMailClient.createMailMessage()

eMessage.Recipient = eMailAddress
eMessage.Subject = eSubject
eMessage.Body = "The text in the message"
AttachmentURL = convertToUrl("c:\users\fjcc\desktop\99Export.txt")
eMessage.Attachement = array(AttachmentURL)
eMailClient.sendMailMessage ( eMessage, )
End Sub
AOO 3.4 or 4.1 on MS Windows XP ( before 2013-08-03) or Windows 7
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
Posts: 5839
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: sending an email from calc with a macro

Postby Zizi64 » Wed Mar 22, 2017 8:57 pm

Code: Select all   Expand viewCollapse view
eMailClient.sendMailMessage ( eMessage, )

or when you want to control the mail client manually:
Code: Select all   Expand viewCollapse view
eMailClient.sendSimpleMailMessage( eMessage, 0 )

My email client is Microsoft Outlook.

Try the ThunderBird e-mail client. It works well for me with similar macro codes.
(And it worked with the old OutlookExpress. I never used the MS Outlook...)
Tibor Kovacs, Hungary; LibreOffice4.4.7 - Portable versions: LO3.3.0-LO5.3.3 and AOO4.1.3; on Win7x64Prof.
Please, edit the topic's initial post, and add the word "[Solved]" at the beginning of the subject line - if your problem has been solved.
User avatar
Posts: 5131
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 9 guests