Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
olaoyesunday1
Contributor III
Contributor III

How to Use VB macros to send Email through Outlook in QlikView

Hi all,

Please, can anyone explain or send me a link that explain step by step on how to us VB Script Macros to Send email through Outlook In QlikView?

Thanks 

Labels (4)
14 Replies
marcus_sommer

I think your approach missed a trigger for the macro. I'm not sure which one are available nowadays. You may try it with OnOpen trigger but I believe it's not supported anymore and you will probably need an OnReload trigger. This would require the parameter /l respectively /r and your call may the look like:

C:\Program Files\QlikView\Qv. exe /l "C:\Test\sendingMails.qvw"

More details to the parameter and it's meaning will you find within the provided link above.

olaoyesunday1
Contributor III
Contributor III
Author

@marcus_sommer Thanks.

I have another issue with my BullZip printer. it was working fine with the code day before yesterday but since yesterday it was saying: ActiveX component can't create object: 'Bullzip.PdfSettings' and it is pointing to this Set obj = CreateObject("Bullzip.PdfSettings") in my code. 

The suggestion that I should re register on regsvr32 path\to\Bullzip.PdfSettings.dll. I searched there nothing like "Bullzip.PdfSettings.dll". 

Can anyone help me out? 

Thanks.

marcus_sommer

I think the registration of any bullzip-libraries is not relevant for your issue because it's very unlikely that a library lose their registration without any bigger changes within the environment. This means any updates from the OS or the tool itself.

Far more likely are any adjustments to the QlikView settings especially to the macro-module settings in the mid of the left pane which needs to be set to allow an external access. Also the various user- and document-settings within tab security may impact the execution of macro-code.

Another look may go to the security-settings of your Windows account/machine because ActiveX might be just disabled (maybe enabling the protected mode within the IE / Edge or similar - which are not really tool-settings else Windows settings) or restricted by any group policy.

olaoyesunday1
Contributor III
Contributor III
Author

@marcus_sommer Thanks it works

it was due to what you said "Far more likely are any adjustments to the QlikView settings especially to the macro-module settings in the mid of the left pane which needs to be set to allow an external access. Also the various user- and document-settings within tab security may impact the execution of macro-code."

under current local security in the Left pane of the QlikVIew macro editor, it was in safe mode, I know changed it to Allow system access and it works.

olaoyesunday1
Contributor III
Contributor III
Author

@marcus_sommer and Any other users,

Hi All,

Please can anyone explain to me how to amend my code below to open outlook app on desktop before sending the report. If the Outlook Desktop App is not opened, the report would be in outbox until the day you open outlook on your desktop before it would send. 

Sub mSendMail(pdfFilePath)
Dim objOutlk
Dim objMail
Const olMailItem = 0

' Create a new instance of Outlook application
Set objOutlk = CreateObject("Outlook.Application")

' Create a new mail item
Set objMail = objOutlk.createitem(olMailItem)

' Recipient's email address
objMail.To = "abcd@example.com"


' Subject of the email
objMail.Subject = "Testing " & Date()

' Body of the email
objMail.HTMLBody = "Body of the email, This is an automatic generated email from QlikView."

' Add attachment (use the generated PDF file)
objMail.Attachments.Add pdfFilePath

' Send the email
objMail.Send

' Release resources
Set objMail = Nothing
Set objOutlk = Nothing
End Sub

What should I add to open the Outlook desktop App if it has not opened? I have used batch file and Task schedular to automate the reloading and sending process but I want to know if macros can open outlook app automatically and send emails.

Thanks.