[Solved] Send email macro

Creating a macro - Writing a Script - Using the API

[Solved] Send email macro

Postby Nelomf » Tue Apr 20, 2021 3:41 pm

Hello

This problem is not related directly with the macro but her it goes.
I do need help

I' sending a email through a OpenOffice basic macro. The default email program is Thunderbird
I use this in several PC's and normally after the code a prompt appear that says "Another application is trying to send mail using this user profile. Do you want to send the email?".

If i press OK the mail goes but in one PC i clicked to not show the warning and i cant send the email.

I want to:

or show again the warning
or even better bypass and always allow sending this email.

Is it possible

Thanks.
Manuel
Last edited by Nelomf on Thu Apr 22, 2021 12:55 pm, edited 1 time in total.
Openoffice 4, Windows 7
Nelomf
 
Posts: 22
Joined: Wed Nov 06, 2019 4:29 pm

Re: Send email macro

Postby Zizi64 » Tue Apr 20, 2021 8:32 pm

Please upload your macro code here.
Tibor Kovacs, Hungary; LO6.1.6, 6.4.7 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.1.1;AOO4.1.9
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
Zizi64
Volunteer
 
Posts: 9941
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Send email macro

Postby Villeroy » Tue Apr 20, 2021 10:26 pm

Why buttons and macros to send mails?
Attachments
t105067.ods
(14.05 KiB) Downloaded 119 times
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
User avatar
Villeroy
Volunteer
 
Posts: 30080
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Send email macro

Postby Nelomf » Wed Apr 21, 2021 8:56 am

God Morning

My macro
Note: It works perfectly on some PC's and others don't and the only problem (I think) it's Thunderbird setup.

Code: Select all   Expand viewCollapse view
Sub Comprasemail
Rem constroi PDF
mypdf

rem define nome do bar no sujeito do email
xSheet = ThisComponent.Sheets(1)
oCell = xSheet.getCellByPosition(1,0)


rem define data de envio do email
Dim basDate As Date
basDate = NOW()

rem enviar email
ThisComponent.store()
rem ----------------------------------------
sPathPDFs = "c:\encomendas\"
eMailAddress = "sede@ccdgondomar.pt"
eSubject ="F. encomendas"&" " & "de"&" " & oCell.string &" "&"enviada em"&" "& Day(basDate)&"/" &Month(basDate) &"/" &Year(basDate)
eBodyText = "Em anexo pode encontrar a minha encomenda da semana"
URL1 = convertToUrl(sPathPDFs & "encomenda.pdf")
rem URL2 = convertToUrl(sPathPDFs & "compras.pdf")
ArrayOfURLs = Array(URL1)
rem ----------------------------------------
eMailer = createUnoService("com.sun.star.system.SystemMailProvider")
eMailClient = eMailer.queryMailClient()     
   eMessage = eMailClient.createMailMessage()     
   eMessage.Recipient = eMailAddress

rem  eMessage.BlindCopy = BCAdresses  ' ??

   eMessage.Subject = eSubject

   eMessage.Body = eBodyText       ' ??

   eMessage.Attachement = ArrayOfURLs

eMailClient.sendMailMessage ( eMessage,com.sun.star.system.MailClientFlags.NO_USER_INTERFACE )

msgbox "A Sua encomenda foi enviada com exito"
ThisComponent.close(True)


End Sub
Last edited by robleyd on Wed Apr 21, 2021 9:06 am, edited 1 time in total.
Reason: Added Code tags
Openoffice 4, Windows 7
Nelomf
 
Posts: 22
Joined: Wed Nov 06, 2019 4:29 pm

Re: Send email macro

Postby Nelomf » Wed Apr 21, 2021 9:47 am

Villeroy wrote:Why buttons and macros to send mails?


Because this sheet is intended to people that have very little understanding of software, they only place some numbers in a predefined table and then press a send button.
It's very easy for them to work this way.
The macros in this sheet filters the content of the sheet, save as pdf and send to me.

That's why.

Tanks
Openoffice 4, Windows 7
Nelomf
 
Posts: 22
Joined: Wed Nov 06, 2019 4:29 pm

Re: Send email macro

Postby Villeroy » Wed Apr 21, 2021 11:38 am

Nelomf wrote:Because this sheet is intended to people that have very little understanding of software

This is the best reason to avoid any kind of spreadsheet. I never see any spreadsheet when something is easy to use. I see spreadsheets as applications mockups for drafting and easy development. With a few keystrokes, with copy&paste or drag&drop all your references, validations, formattings are futile. Easy to make is opposed to easy to use and vice versa.
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
User avatar
Villeroy
Volunteer
 
Posts: 30080
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Send email macro

Postby Nelomf » Thu Apr 22, 2021 12:55 pm

Solved

I've installed in some computers a 64bit version of thunderbird and shoud be a 32 bit.
It works fine.

I will also try to set mapi.blind-send.enabled = to true or false to see if the message (Allow from external program...)appear or not.
~
Finally a question. Is it possible to close thunderbird (from the macro) after the mail goes out.

Thanks
Openoffice 4, Windows 7
Nelomf
 
Posts: 22
Joined: Wed Nov 06, 2019 4:29 pm

Re: Send email macro

Postby Nelomf » Thu Apr 22, 2021 12:58 pm

Villeroy wrote:
Nelomf wrote:Because this sheet is intended to people that have very little understanding of software

This is the best reason to avoid any kind of spreadsheet. I never see any spreadsheet when something is easy to use. I see spreadsheets as applications mockups for drafting and easy development. With a few keystrokes, with copy&paste or drag&drop all your references, validations, formattings are futile. Easy to make is opposed to easy to use and vice versa.


It's your opinion, i respect but dont agree.

Thakns
Openoffice 4, Windows 7
Nelomf
 
Posts: 22
Joined: Wed Nov 06, 2019 4:29 pm


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 3 guests