[Solved] Macro doesn't send mail with attachment

Creating a macro - Writing a Script - Using the API

[Solved] Macro doesn't send mail with attachment

Postby ubrew » Thu Apr 23, 2020 3:40 pm

Hi,

I'can't find out a solution for this issue.
When I execute this macro I receive this error message: Property or method not found: "Attachement".
If I comment that line everything is fine, a thunderbird window opens and all the data are in the message, obviously the attachment is missing.


Code: Select all   Expand viewCollapse view
sub mail
   Dim MailAgent As Object
   Dim MailClient As Object
   Dim MailMessage As Object
   Dim UI As Integer
   Dim eMailer, eMailClient, eMailMessage As Object
   Dim sAddress as string
   Dim sAddressFrom As String
   Dim Object As String
   Dim Attachment As String

   Attachment="file:///mnt/prova.pdf"
   sAddressFrom="mittente@example.com"   
   sAddress="destinatario@example.com"
   Object="Prova"
   eMailer=createUnoService( "com.sun.star.system.SystemMailProvider" )
   eMailClient=eMailer.queryMailClient()
   eMailMessage=eMailClient.createMailMessage()
   eMailMessage.Recipient=sAddress
   eMailMessage.Subject=Object
   eMailMessage.Body="Vedi allegato"
   eMailMessage.Originator=sAddressFrom
   eMailclient.Attachement=Array(Attachment)
   eMailClient.sendMailMessage(eMailMessage,0)     

end sub


Thanks
Last edited by ubrew on Thu Apr 23, 2020 4:47 pm, edited 1 time in total.
OpenOffice 4.1.7 on Linux Mint 19.1 Cinnamon
ubrew
 
Posts: 2
Joined: Thu Apr 23, 2020 3:30 pm

Re: Macro doesn't send mail with attachment

Postby JeJe » Thu Apr 23, 2020 4:19 pm

Its the emailmessage that has an attachement, not the emailclient

You can find this out easily using MRI.
Openoffice 4.1.2
Windows 8
JeJe
Volunteer
 
Posts: 1088
Joined: Wed Mar 09, 2016 2:40 pm

Re: Macro doesn't send mail with attachment

Postby ubrew » Thu Apr 23, 2020 4:45 pm

Thank you very much JeJe!
Now it works, I'll check MRI and put Solved on this post.
Thanks
OpenOffice 4.1.7 on Linux Mint 19.1 Cinnamon
ubrew
 
Posts: 2
Joined: Thu Apr 23, 2020 3:30 pm


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 4 guests