Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Trigger onPostReload

Hi All,

I have assigned the macro(Send mail) onPostRelod trigger, so when we reload the application, it sends mail.

It is fine, when click icon of reload.

but, through batch file, it doesn't send mail. ("C:\Program Files\QlikView\Qv.exe"   /r "Path\Currency.qvw")

Pls help me on this.

Regards,

Kabilan K.

5 Replies
Anonymous
Not applicable
Author

Hi Kabilan,

This is a very common question on these forums. If you search around a bit you'll find plenty of examples.

Basically what happens is that when you run the /r switch QlikView will only run the script part and not your onPostReload trigger macros.

What you probably want to do is to create a vbscript to load QV.exe, open the file, run the reload, run the macro code, save the application, close document, close QV.exe.

Then you can schedule this vbscript to run.

Not applicable
Author

How to run the macro through VBS?

Could u pls give the script?

Not applicable
Author

try using /l instead of /r

and also write 'exit' in the batch file at the end.

Regards,

Amay

Not applicable
Author

No it is not working..

I am using Supporting task to schedule the batch file, not windows task scheduler.

Hi Johan,

I have written the vbs like below.

set Qv = CreateObject("QlikTech.QlikView")

Qv.OpenDoc "F:\qvsdocs\binary\publish\test1.qvw"

set QvDoc = Qv.ActiveDocument

QvDoc.GetApplication().WaitForIdle

QvDoc.Save

QvDoc.GetApplication().WaitForIdle

QvDoc.CloseDoc

Qv.Quit

and I have written batch file like below

In onopen trigger I have written the Send mail macro.

cscript F:\sendmail.vbs

In supporting task, I have mentioned this bat file.

However it didn't work.

But, It works when we double click the bat file directly.

Pls give a idea on this.

Regards,

Kabilan K.

Not applicable
Author

I have tried as u told.

set Qv = CreateObject("QlikTech.QlikView")

Qv.OpenDoc "F:\qvsdocs\binary\publish\test1.qvw"

set QvDoc = Qv.ActiveDocument

Dim objEmail

    Dim strMailTo

    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

    Const SMTPServer = "Smtp name"

    Const SMTPPort = 25                 ' Port number for SMTP

    Const SMTPTimeout = 60              ' Timeout for SMTP in seconds

        'Send 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 = "eamailaddress.com"

        objEmail.From = "eamailaddress.com"

        objEmail.Subject = "Test mail"

        objEmail.TextBody = "Body"

        objEmail.Send

        Set objFlds = Nothing

        Set objConf = Nothing

        Set objEmail = Nothing

QvDoc.GetApplication().WaitForIdle

QvDoc.Save

QvDoc.GetApplication().WaitForIdle

QvDoc.CloseDoc

Qv.Quit

note: I want to attach the image of chart in the body, that's Y I want to open the application.

Through batch file I have run this vbs file in supporting task. it didn't send a mail. but task run sucessfully.

If we run the send mail vbs alone and use supporting task  then it works fine

  Dim strMailTo

    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

    Const SMTPServer = "smtp name"

    Const SMTPPort = 25                 ' Port number for SMTP

    Const SMTPTimeout = 60              ' Timeout for SMTP in seconds

        'Send 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 = "eamailaddress.com"

        objEmail.From = "eamailaddress.com"

        objEmail.Subject = "Test mail"

        objEmail.TextBody = "Body"

        objEmail.Send

        Set objFlds = Nothing

        Set objConf = Nothing

        Set objEmail = Nothing

Pls help me on this some one.

Regards,

Kabilan K.