Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
linoyel
Specialist
Specialist

Sending QV object by e-mail using Macro

Hey all,

I need your help in Macro issue.

I need an e-mail with a QV document certain objects to be sent daily.

I understand it's possible to write Marco that does it, but the only option with examples I've found meanwhile is creating a button that runs Macro. This is not a good solution in my case, cause I need the e-mail to be sent every day automatically (by schedule), without waiting that someone will press the button to send an e-mail...

Is there an outside-of-Qliqview option to write a VB script for sending e-mails?

If there is, please give me some examples to implement this (I have no idea of writing Macros..)

Thank you!

20 Replies
Not applicable

Hi Linoy,

Hope this will help you.

http://community.qlik.com/docs/DOC-3772

fkeuroglian
Partner - Master
Partner - Master

Hi Linoy

One Solution could be create a qvw that have the macro to send the email, and then create  a windows task that call this qvw and execute  the macro.

the task would be automatic and you can set the hour and others configurations.

Tell me if you need something

Good luck

Fernando

arsal_90
Creator III
Creator III

Hi Linoy

Please find the attached word file and follow the mention steps in word you can achieve your goal.

linoyel
Specialist
Specialist
Author

Thank you for your help!

All answers were great and helped me a lot in understanding the subject.

I also found a nice explanation how to activate Macro code using triggers (instead of a button):

Qlikview Auto Reload Macro by RFB 78 - YouTube

linoyel
Specialist
Specialist
Author

Hi Fernando!

Thanks - that seems to be a great solution for me and I'll certainly try it.

Although, is it possible to write a Macro in one qvw that emails objects from another qvw?

What's the code for it?

arsal_90
Creator III
Creator III

  1. 1. Install Bullzip PDF Printer (I tried CutePDF, PDF X-change, PdfCreator,.. bullzip is the only one that works)

  1. 2. Macro :

Sub Dagrapport

vReport = “QVreportname” ‘Set report

vName = “reportname” ‘Name of output pdf

  1. ActiveDocument.PrintReport(vReport), “Bullzip PDF Printer”, false ‘Printreport

reportFile = “reportpath” & vName &”.pdf” ‘Setting outputname

MyPrintPDFWithBullZip(reportFile) ‘Call pdf printer

  1. ActiveDocument.GetApplication.Sleep 5000

zendDagrapport

End sub

FUNCTION MyPrintPDFWithBullZip (pdfOutputFile)

set obj = CreateObject(“Bullzip.PDFPrinterSettings”)

  • obj.SetValue “Output” , pdfOutputFile
  • obj.SetValue “ConfirmOverwrite”, “no”
  • obj.SetValue “ShowSaveAS”, “never”
  • obj.SetValue “ShowSettings”, “never”
  • obj.SetValue “ShowPDF”, “no”
  • obj.SetValue “RememberLastFileName”, “no”
  • obj.SetValue “RememberLastFolderName”, “no”
  • obj.SetValue “ShowProgressFinished”, “no”
  • obj.SetValue “ShowProgress”, “no”
  • obj.WriteSettings True

END FUNCTION

‘===========================================================================

‘===========================================================================

function zendDagrapport()

Dim objEmail

Const cdoSendUsingPort = 2 ‘ Send the message using SMTP

Const cdoAnonymous = 0 ‘Do not authenticate

Const cdoBasic = 1 ‘basic (clear-text) authentication

Const cdoNTLM = 2 ‘NTLM

SMTPServer = “IP Mailserver

Const SMTPPort = 25 ‘ Port number for SMTP

Const SMTPTimeout = 60 ‘ Timeout for SMTP in seconds

‘Sending mail

Set objEmail = CreateObject(“CDO.Message”)

Set objConf = objEmail.Configuration

Set objFlds = objConf.Fields

With objFlds

‘---------------------------------------------------------------------

‘ SMTP server details

.Item(“http://schemas.microsoft.com/cdo/configuration/sendusing”) = cdoSendUsingPort

.Item(“http://schemas.microsoft.com/cdo/configuration/smtpserver”) = SMTPServer

.Item(“http://schemas.microsoft.com/cdo/configuration/smtpauthenticate”) = cdoAnonymous

.Item(“http://schemas.microsoft.com/cdo/configuration/smtpserverport”) = SMTPPort

.Item(“http://schemas.microsoft.com/cdo/configuration/smtpusessl”) = False

.Item(“http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout”) =

SMTPTimeout

.Update

‘---------------------------------------------------------------------

End With

  • objEmail.To = “to emailaddress” ‘Email Recipient
  • objEmail.From = “from emailaddress” ‘Email Sender
  • objEmail.Subject = “emailsubject” ‘ Subject
  • objEmail.TextBody = “emailbody” ‘Text Body

end function

fkeuroglian
Partner - Master
Partner - Master

Linoy

You would export the object before?

You could export before the object or you could replicate the objects and put in the new qvw.

could be a copy of the first qvw that only the diferences is that have this macro send email pherhaps

linoyel
Specialist
Specialist
Author

The original qvw runs every hour (and it's very heavy, it runs for 25 mins) but I need to send a certain object from it only once a day (this specific object changes once a day as well).

fkeuroglian
Partner - Master
Partner - Master

Ok, perfect

You could export the objects to some local folder and then the new qwv wiit the macro will import and attached in the email

your macro will attach them

i send you the macro to send email with object attached