Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Mail report to users

HI all,

     I have a qvw which contains a reort. I want to mail it as pdf attachment to users. I have searched for solutions in this forum. Below is what i taked (Maco script), But i didnt work. Any suggestion please?

SUB MailReport

    DIM objEmail

    DIM varDate

    DIM v

    SET v = ActiveDocument.Variables("vDate")

varDate = v.GetContent.STRING

    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 = "[Mail Sever address]"

    CONST SMTPPort = 25                 ' Port number for SMTP

    CONST SMTPTimeout = 30              ' 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 = "[recipient account]"        'Email Recipient

    'objEmail.Cc = "[Insert Email]" 'Carbon Copy Recipient

    objEmail.From = "[sender account]"                        'Email Sender

    objEmail.SUBject = "QlikView Automated Excel Report"                        ' Subject

    objEmail.TextBody = "QV Report - Excel File Attached. This email is an automated procedure generated by QlikView."        'Text Body         

    objEmail.AddAttachment   "D:\test.xlsx"    ' Attachment

    objEmail.SEND

    SET objFlds = NOTHING

    SET objConf = NOTHING

    SET objEmail = NOTHING

END SUB

0 Replies