Tuesday, July 10, 2012

QlikView - Send Report as Email

First Create Report






You should install Bullzip PDF printer.
You can download it from here
http://www.bullzip.com/products/pdf/info.php

Send Email



Please Don’t forget to set macro module security on System Access/Allow System Access

Send Mail Coding

Sub SendReport
ActiveDocument.Sheets("SH01").Activate
    'ActiveDocument.reload
    vReport = "RP01" 'Set report
    vName = "StatisticsReport" 'Name of output pdf
    ActiveDocument.PrintReport(vReport),"Bullzip PDF Printer",false  'Printreport
    reportFile = "C:\Users\gowri\Desktop\" & vName &".pdf" 'Setting outputname
    MyPrintPDFWithBullZip(reportFile) 'Call pdf printer
    ActiveDocument.Sheets("SH01").Activate
    
    MyPrintPDFWithBullZip_Transaction(File_Transaction) 'Call pdf printer
    ActiveDocument.GetApplication.Sleep 5000
    'mailrapport
    'SendMail
    ActiveDocument.Save
    ActiveDocument.GetApplication.Sleep 5000
    'ActiveDocument.GetApplication.Quit
End sub

FUNCTION MyPrintPDFWithBullZip(pdfOutputFile)

    'set obj = CreateObject("Bullzip.PDFPrinterSettings")
    set obj = CreateObject("Bullzip.PdfSettings")
    obj.PrinterName = "Bullzip PDF Printer"
    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

Sub SendMail() 

' Object creation 
Set objMsg = CreateObject("CDO.Message") 
Set msgConf = CreateObject("CDO.Configuration") 

' Server Configuration 
'msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 
'msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com" 
'msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465 
'msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 
'msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "###@gmail.com" 
'msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "#########" 
'msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = 1 
'msgConf.Fields.Update

msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 
msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "1##.###.###.###" 
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") = "#####" 
msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "#######" 
'msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = 1 
msgConf.Fields.Update 

'Dim rightNow As DateTime
'rightNow = DateTime.Now
'Dim strCurrentDateTimeString As String
'strCurrentDateTimeString = rightNow.ToString("dd/mm/yyyy")

strDate = CDate(Date)
strDay = DatePart("d", strDate)
strMonth = DatePart("m", strDate)
strYear = DatePart("yyyy", strDate)
' Email
objMsg.To = "####@esolutionsroad.com"
objMsg.cc = "####@esolutionsroad.com"

objMsg.From = "reports@####.com" 
objMsg.Subject = "Trial Report - Portal Registrations & Transactions - Daily Stats - " &strDay&"/"&strMonth&"/"&strYear
objMsg.HTMLBody = "<html><body>Dears,<br><br>Please find portal registration and transaction statistics in detail as of <b>" &strDay&"/"&strMonth&"/"&strYear & "</b>.<br><br>Thanks,<br><br>Biz Dashboard Opz Team.</body></html>"
objMsg.AddAttachment  "C:\Users\Gowri\Desktop\StatisticsReport.pdf"

Set objMsg.Configuration = msgConf 

' Send 
objMsg.Send

' Clear 
Set objMsg = nothing 
Set msgConf = nothing

End Sub





2 comments:

  1. Your site is just like an online guide that is very helpful for the Qlikview learners, thanks for the useful data. QlikView Training in Hyderabad

    ReplyDelete
  2. Traditional OLAP/cube technologies primarily provide the ability to drill up and down through “dimension” hierarchies, allowing the end-user to see pre-aggregated “measures.This is a great and interesting post that you shared.I am sure that the players will really love to read this informative post of you.More power!.thanks.qlikview training in hyderabad

    ReplyDelete