[Solved] Attachment into email with Hyperlink - mailto
[Solved] Attachment into email with Hyperlink - mailto
Hello, is it possible to get attachment to email with the function Hyperlink? I have this function:
HYPERLINK("mailto:"&A1&"?subject="&B1&"&body="&C1&"&attach='c:\test.ods'";A1)
It works perfectly BUT without attachment. Can anybody to help?
(So it opening Thunderbird new email window ... maybe it is important)
HYPERLINK("mailto:"&A1&"?subject="&B1&"&body="&C1&"&attach='c:\test.ods'";A1)
It works perfectly BUT without attachment. Can anybody to help?
(So it opening Thunderbird new email window ... maybe it is important)
Last edited by lodovi on Mon Nov 21, 2016 12:21 pm, edited 1 time in total.
Re: Attachment into email with Hyperlink - mailto
There are a couple of subjects on this matter on mozillazine forums - Thunderbird does not accept attachment parameter in mailto links, so this is impossible. A few of the email clients will, like for ex. Evolution on LInux. You could try building a link that would invoke thunderbird with -compose param, but that would be very machine-specific (path to thunderbird exe).
OpenOffice 4.1.3 on Windows 10 x64
Re: Attachment into email with Hyperlink - mailto
Thank you. I tried macro from here http://ooo-forums.apache.org/en/forum/v ... 7&p=379776 but it looks like it does not work in LO (mabe only in AOO, but I do not tried it). Is it posible to use (or modify) this macro for LO
Code: Select all
Sub TestMailer
Dim eMailAddress as String
Dim eSubject as String
Dim eMailer as Object
Dim eMailClient as Object
eMailAddress = "trnka@autonapul.cz"
eSubject = "Test email"
eMailer = createUnoService("com.sun.star.system.SystemMailProvider")
eMailClient = eMailer.queryMailClient() 'Here is a mistake
eMessage = eMailClient.createMailMessage()
eMessage.Recipient = eMailAddress
eMessage.Subject = eSubject
'eMessage.CcRecipient = Array("dummy2@gmail.com")
'eMessage.BccRecipient = Array("dummy@gmail.com")
eMessage.Body = "This is the text of the test message."
AttachmentURL = convertToUrl("d:\_prace\ksefty\OO_pokusy\vzorec3.jpg")
eMessage.Attachement = Array(AttachmentURL)
eMailClient.sendMailMessage ( eMessage, com.sun.star.system.MailClientFlags.NO_USER_INTERFACE )
End Sub
LibreOffice 5.2.2.2. OS Win 7
Re: Attachment into email with Hyperlink - mailto
Look up what com.sun.star.system.SystemMailProvider offers. You will find this at
https://www.openoffice.org/api/docs/com ... vider.html
I think you need to use XSystemMailProvider.
https://www.openoffice.org/api/docs/com ... vider.html
I think you need to use XSystemMailProvider.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
Re: Attachment into email with Hyperlink - mailto
OK, than you, but here http://api.libreoffice.org/docs/idl/ref ... ystem.html i can not find "XSystemMailProvider".RoryOF wrote:Look up what com.sun.star.system.SystemMailProvider offers. You will find this at
https://www.openoffice.org/api/docs/com ... vider.html
I think you need to use XSystemMailProvider.
LibreOffice 5.2.2.2. OS Win 7
Re: Attachment into email with Hyperlink - mailto
I can't answer for what LibreOffice provides. I can find it in the OpenOffice API. If you are using LibreOffice you may need to rewrite the macro.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
Re: Attachment into email with Hyperlink - mailto
We are using the
with LO 4.4.7 version and the Thunderbird E-mail client on Win7, and it works fine. The Thunderbird must be the default e-mail client.
Code: Select all
eMailer = createUnoService( "com.sun.star.system.SimpleSystemMail" )
Code: Select all
Dim eMailAddress as String
Dim eSubject as String
Dim eMailer as Object
Dim eMailClient as Object
Dim eMessage as Object
eMailAddress = "Somebody@SomeService.com"
eSubject = "The subject string"
eMailer = createUnoService( "com.sun.star.system.SimpleSystemMail" )
eMailClient = eMailer.querySimpleMailClient()
eMessage = eMailClient.createSimpleMailMessage()
eMessage.setRecipient(eMailAddress)
eMessage.setSubject(eSubject)
eMessage.setAttachement (Array("TheUrlOfTheAttachment"))
eMessage.body="Body text"
eMailClient.sendSimpleMailMessage( eMessage, 0 ) 'The client will pop up, and the user will send the constructer email message, manually.
' eMailClient.sendSimpleMailMessage ( eMessage,com.sun.star.system.SimpleMailClientFlags.NO_USER_INTERFACE ) 'silent sending
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
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.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
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.
Re: Attachment into email with Hyperlink - mailto
Thank very much to Zizi64. I found something similar but whitout this: eMessage.body="Body text" and I did not find a possibility here: http://api.libreoffice.org/docs/idl/ref ... ssage.html
Your code is perfect.
Your code is perfect.
LibreOffice 5.2.2.2. OS Win 7
Re: [Solved]Attachment into email with Hyperlink - mailto
Use the "MRI" or the "Xray tool" extension for examine and display the existing properties, methods, interfaces of the objects.I found something similar but whitout this: eMessage.body="Body text"
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
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.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
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.
Re: [Solved]Attachment into email with Hyperlink - mailto
Here is complete solution. First is for button and second is for HYPERLINK.
and macros. Everything is testing only in LO 5.2.
Code: Select all
=HYPERLINK("vnd.sun.star.script:Standard.Module1.HyperSendMail?language=Basic&location=document&MailAddress="&A1&"&Subject="&A2&"&Body="&A3&"&Attach="&A4;"Send e-mail")
Code: Select all
Sub SendMail 'this is solution for button (variables in czech language)
doc = thisComponent
list = doc.getCurrentController.getActiveSheet
adresa = list.GetCellRangeByName("A1").string
predmet = list.GetCellRangeByName("A2").string
telo = list.GetCellRangeByName("A3").string
priloha = list.GetCellRangeByName("A4").string
Mailer (adresa, predmet, telo, priloha)
end sub
Sub HyperSendMail (sURL$) 'this is solution for function HYPERLINK in the sheet (variables in czech language)
adresa = getArgumentFromURL(sURL,"MailAddress")
predmet = getArgumentFromURL(sURL, "Subject")
telo = getArgumentFromURL(sURL, "Body")
priloha = getArgumentFromURL(sURL, "Attach")
Mailer (adresa, predmet, telo, priloha)
End Sub
Sub Mailer (eMailAddress as String, eSubject as String, eBody as String, Attachment as String)
Dim eMailer as Object
Dim eMailClient as Object
Dim eMessage as Object
Dim nFlag as integer
nFlag = 0
eMailer = createUnoService( "com.sun.star.system.SimpleSystemMail" )
eMailClient = eMailer.querySimpleMailClient()
eMessage = eMailClient.createSimpleMailMessage()
eMessage.setRecipient(eMailAddress)
eMessage.setSubject(eSubject)
if Attachment <> "" Then
eAttachmentURL = convertToUrl(Attachment)
eMessage.setAttachement (Array(eAttachmentURL))
end if
eBody = Replace(eBody,"*",chr(10))
eMessage.body = eBody
eMailClient.sendSimpleMailMessage( eMessage, nFlag)
End Sub
REM returns "" if no value was found for name.
Function getArgumentFromURL(sURL$,sName$) as String
on error goto exitErr:
Dim iStart%, i%, l%, sArgs$, a()
iStart = instr(sURL, "?")
l = len(sName)
if (iStart = 0) or (l = 0) then exit function
' sArgs behind "?":
sArgs = mid(sURL, iStart +1)
a() = split(sArgs, "&")
for i = 0 to uBound(a())
' not case sensitive:
if instr(1, a(i), sName &"=", 1) = 1 then
getArgumentFromURL = mid(a(i), l +2)
exit for
endif
next
exitErr:
' return ""
End Function
LibreOffice 5.2.2.2. OS Win 7
Re: [Solved]Attachment into email with Hyperlink - mailto
You know that address, subject, body and attachment path must not contain = nor &
I'd suggest range arguments SH, SR, ER, SC, EC for sheet, start row, end row, start column and end column using SHEET(), ROW(), COLUMN() with offsets
"&SH="&SHEET()&"&SR="&ROW()&"&EH="&ROW()&"&SC=1&EC=4"
which gives in row #3 of sheet #1
&SH=1&SR=3&ER=3&SC=1&EC=4
referring to columns A to D in this column on this sheet.
The macro fetches the range like this:
ThisComponent.Sheets(sh -1).getCellRangeByPosition(sc -1, sr -1, ec -1, er -1)
I'd suggest range arguments SH, SR, ER, SC, EC for sheet, start row, end row, start column and end column using SHEET(), ROW(), COLUMN() with offsets
"&SH="&SHEET()&"&SR="&ROW()&"&EH="&ROW()&"&SC=1&EC=4"
which gives in row #3 of sheet #1
&SH=1&SR=3&ER=3&SC=1&EC=4
referring to columns A to D in this column on this sheet.
The macro fetches the range like this:
ThisComponent.Sheets(sh -1).getCellRangeByPosition(sc -1, sr -1, ec -1, er -1)
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
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice