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 78 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: 6512
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; LO4.4.7, LO5.4.7 on Win7x64Prof.
PortableApps, winPenPack: LO3.3.0-LO6.0.4 and AOO4.1.5
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
Posts: 6714
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 15 guests