Ask Your Question
0

Send email from LO

asked 2017-12-17 18:07:42 +0200

Zeke99 gravatar image

I'm trying to convert from aoo to LO but I cannot get the email-macro to work. Today I'm using the following code:

sub send_email(filepath as String, eMailAdress as String, eyourorder as String)

'Dim eMailAdress as String
Dim eSubject as String
Dim eMailer as Object
Dim eMailClient as Object
Dim eMessage as Object
Dim n as Integer
Dim t, s as string

n=FreeFile()
Open "home/prm/Affarssystem/txt/Orderconftxt" for Input as #n
Seek(n, 1)
Do While NOT EOF(n)
    Line Input #n, s
    t=t & CHR$(10) & s
Loop
Close #n

eSubject = "Order Confirmation " & eyourorder
eMailer = createUnoService("com.sun.star.system.SystemMailProvider") REM sätt brödtext  
eMailClient = eMailer.queryMailClient()
eMessage = eMailClient.createMailMessage()
eMessage.Recipient = eMailAdress
eMessage.Subject=eSubject
eMessage.Body=t
eMessage.Attachement=(Array(convertToUrl(filepath)))
eMailClient.sendMailMessage ( eMessage, com.sun.star.system.MailClientFlags.NO_USER_INTERFACE )

In LO I recieve Basic runtime error. Object variable not set when executing the row eMailClient=eMailer.queryMailClient(). If I xray eMailer in LO it says that eMailer is empty(null) so com.sun.star.system.SystemMailProvider is obviously not working. Does anyone know the LO equivalent for SystemMailProvider?

edit retag flag offensive close merge delete

Comments

com.sun.star.system.SimpleSystemMail

Mike Kaganski gravatar imageMike Kaganski ( 2017-12-17 19:08:43 +0200 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2017-12-17 21:16:48 +0200

Zeke99 gravatar image

updated 2017-12-17 21:19:34 +0200

After testing some different solutions this is what's working for me:

eSubject = "Order Confirmation " & eyourorder eMailer = createUnoService("com.sun.star.system.SimpleCommandMail")

eMessage = eMailer.createSimpleMailMessage()

eMessage.recipient = eMailAdress

eMessage.subject=eSubject

eMessage.body=t

eMessage.attachement=(Array(convertToUrl(filepath)))

eMailClient.sendSimpleMailMessage ( eMessage, com.sun.star.system.SimpleMailClientFlags.NO_USER_INTERFACE )

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2017-12-17 18:07:42 +0200

Seen: 80 times

Last updated: Dec 17 '17