Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Not applicable

Macros automailing

Hi frriends,

I am Using Macros to send the mail automatically...but in the Subject Body along with the name i shud mention the dealercode how i can do this.

ex: I hav subject as "Monthly Analysis Report" instead of this i wont as "Monthly Analysis Report_DealerCode" means as the pdf is generated for each dealer that particular code also has to be mentioned "Monthly Analysis Report_DLO45'  like dis how can i do this... i hve attached part of my code.

'FUNCTION FOR SENDING MAIL USING SMTP

function sendMail(attachfile)

    Dim filesys

    Dim fileTest

    Dim objEmail

    Dim strMailTo

       Set fileTest = CreateObject("Scripting.FileSystemObject")

      

    currentStatus = fileTest.FileExists (attachfile)       

    if currentStatus = false then

        rem ** let QV sleep for 1 seconds **

        ActiveDocument.GetApplication.Sleep 1000

        'msgbox ("No files to attach")

        set fileTest = nothing

        exit function

    end if   

    set fileTest = nothing

   

    Const cdoSendUsingPort = 2         ' Send the message using SMTP

    Const CdoReferenceTypeName = 1

    Const cdoAnonymous = 0                 'Do not authenticate

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

    Const cdoNTLM = 2                      'NTLM        

    Const SMTPServer = "192.168.61.200" 'SMTP IP

    Const SMTPPort = 25                    'Port number for SMTP

    Const SMTPTimeout = 60                 'Timeout for SMTP in seconds        

    Set objSelected = ActiveDocument.Fields("Email").GetPossibleValues("300")

   

    Set objCCSelected = ActiveDocument.Fields("CCMail").GetPossibleValues("300")

                        

    if objSelected.Count = 0  and  objCCSelected = 0 then   ' Nothing Selected

        'msgbox ("No e-mail reciepient selected")

        exit function

    else    

        Set objEmail = CreateObject("CDO.Message")

        Set objConf = objEmail.Configuration

        Set objFlds = objConf.Fields

        Set v = ActiveDocument.Variables("vlast_week")

       

        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/smtpserverport") = SMTPPort

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

            .Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "abc@gmail.com"

            .Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "password"

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

            .Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = SMTPTimeout

            .Update

        End With    

       

       

                                               

        For i = 0 to objSelected.Count-1 ' create mailTo list

            strMailTo = strMailTo & objSelected.Item(i).Text & ";"   

           

        next   

              

              

        For j = 0 to objCCSelected.Count-1 ' create mailCC list

            strMailCc = strMailCc & objCCSelected.Item(j).Text & ";"           

           

        next 

          

        With objEmail

            Set .Configuration = objConf

                .From =

                .To = strMailTo  "xyz" strMailTo' getvariable("vEmail")  'strMailTo

         

                'msgbox (strMailTo)  

                .BCC = 

                .Subject = "Monthly AnalysisReport" '& ActiveDocument.Evaluate("v")

Tags (1)
2 Replies

Re: Macros automailing

Text in mail:

objEmail.TextBody = "abc ...."

I don't know if ActiveDocument.Evaluate could work right - perhaps it is better this part from .subject to take from attachfile-string: mid(attachfile, index(attachfile, "_"), 5)

- Marcus

Not applicable

Re: Macros automailing

Community Browser