Qlik Community

Ask a Question

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
Join this live chat April 6, 10AM EST - QlikView to Qlik Sense REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Exportar varias tablas a un archivo html

Hola,

comparto con todos el código que usar para mandar mails con las tablas pegadas en el cuerpo del mensaje.

Lo que necesito es que en el html se peguen varias tablas, no solo una, y a poder ser poder insertar el texto que yo quiera entre las tablas.

De momento solo consigo poner una tabla pero necesita unas 4 o 5.

Gracias!!!

MI CODIGO:

'// ****************************************************************

'// Enviador Mails Pegados Cuerpo

'// ****************************************************************

sub SendMail

if Time()>TimeValue("10:15:00") and Time()<TimeValue("21:30:00")Then

  ' Object creation 

Set objMsg = CreateObject("CDO.Message") 

Set msgConf = CreateObject("CDO.Configuration") 

strDate = CDate(Date)

set cs = ActiveDocument.GetSheetObject("CH80")

cs.ExportHtml "C:\Directory\Pruebas\informe.html"

objMsg.CreateMHTMLBody "file://C:\Directory\Pruebas\informe.html"  

' Server Configuration 

msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2  

msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "server***********"  

msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25  

msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1  

msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "mimai********l"  

msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "pass******"  

msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = 1  

msgConf.Fields.Update 

' Email 

objMsg.To = "mmail***********" 

objMsg.From = "mail**********.com" 

objMsg.Subject = "Reporte "    & Now()

objMsg.Sender = "Reportes" 

Set objMsg.Configuration = msgConf 

' Send 

objMsg.Send 

' Clear 

Set objMsg = nothing 

Set msgConf = nothing

end if

end sub

30 Replies
nesawant
Contributor II
Contributor II

Thanks Marcus. This works.

dmohanty
Partner
Partner

marcus_sommer‌,

Hey Buddy,

Nice solution. I could use this for my purpose.

But it's not triggering the email when reloaded in Publisher. The Log has a below message -

Information: Unified Hub: Not configured.


  1. The Trigger 'OnPostReload' is not working after reload in Publisher.
  2. The Macro button too not working in AJAX mode.


Can you please help here?

marcus_sommer
MVP & Luminary
MVP & Luminary

Macros don't work within the AJAX-client - you will need to use the IE plugin or the desktop client. Maybe it's a workaround to use the mailto-protocol and to include a text-table within the body. See for this:

Re: Launching outlook with a standard template

Tables to text: an example

Also the qmc execute no macros - I assume the reason for this is the missing of an object-model, the the qmc respectively the qvb.exe just update the datamodel and no gui exists for it and therefore no trigger/macros are applicable.

An alternatively could be to use an EXECUTE statement to run per batch the desktop client or to run an external vbs-script. See here an example what is meant: Re: QlikView vbs open doc in new window.

- Marcus

dmohanty
Partner
Partner

marcus_sommer‌,

Hey buddy,

Thanks for a quick help here. I will refer all the threads you have suggested and will try to create a work around.

Will get back

dmohanty
Partner
Partner

Hey marcus_sommer‌,

Until yesterday, everything was good in the Macro. It was working perfectly. Suddenly I am getting the below highlighted message/error.

Can you please guide what is this?

Macro Error.png

marcus_sommer
MVP & Luminary
MVP & Luminary

Maybe there is somewhere an eof-char ... it's not quite clear for me why the vbs read-statement should fail on this point. I would try to find the exact breaking-point by including some msgbox-statements within the script, for example the loop-counter i and some further steps - because the editor is sometimes misleading on this point. If you have found this point a msgbox with err.number & err.description might give further hints what's going wrong.

I assume that there is any issue with the text-file and opening it with an editor like notepad++ and if possible comparing it with a former working version will also show what is happening.

- Marcus

nesawant
Contributor II
Contributor II

Hello,

Is there a  way to use CSS styling in macro? My macro stops as soon as I use any CSS styling parameters.

Best regards,

Neha

marcus_sommer
MVP & Luminary
MVP & Luminary

Take a look on the second paragraph here: Re: Exportar varias tablas a un archivo html

- Marcus

dmohanty
Partner
Partner

marcus_sommer‌,

Actually its throwing an error while writing the first HTML (HTML 0). So it's unable to read all the HTML.

Not sure why the HTML is not getting saved. As I have four Chart IDs, so 4 HTMLs are supposed to be created (it was being created also before also). But now, the HTML 0 is showing 0 KB and not failing to be created.

dmohanty
Partner
Partner

marcus_sommer

I just tried to delete the first Chart Id (which was causing the HTML 0 to fail to save), and recreated it again. It worked fine. All the HTML got saved and Master HTML was formed.

This has started working again.