Skip to main content
Announcements
See why Qlik is a Leader in the 2024 Gartner® Magic Quadrant™ for Analytics & BI Platforms. Download Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Kushal_Chawda

Urgent help on Email macro

Dear All,

I am facing some issue with this macro.

I am sending excel file via email through this macro. But when excel file ectension is .xlsx it's not working... when excel file extemsion is .xls it's working fine..

Please suggest some points.

function getVariable(varName)

    set v = ActiveDocument.Variables(varName)

    getVariable = v.GetContent.String

   

set V = ActiveDocument.Variables("vToday")   

vToday = V.GetContent.String

end function  

'================== The Function To mail the CSV file ========================   

function sendnewMail()

    dim reportFiles

    Dim objEmail

    Dim strMailTo

    

    'dim appname1

    'dim appname2

    'dim appname3

    'dim appname4

    dim appname5

    dim appname6

    

   

    Const cdoSendUsingPort = 25    

    ' Send the message using SMTP

    'Const cdoBasicAuth = 1        

    ' Clear-text authentication

    Const cdoTimeout = 60          ' Timeout for SMTP in seconds

    'Const cdoPort = 25            

    ' Port number for SMTP

    Const cdoNTLM = 2

   

    'Const cdoDSNSuccessFailOrDelay = 14 'Success, failure or delay

'====== Create excel sheet containing the field name "emailid" we intend to send the reports ========   

    Set objSelected = ActiveDocument.Fields("emailid").GetPossibleValues

       

    if objSelected.Count = 0 then ' Nothing Selected

        msgbox ("No e-mail reciepient selected")

        exit function

    else

        'Sending mail        

        Set objEmail = CreateObject("CDO.Message")

        Set objConf = objEmail.Configuration

        Set objFlds = objConf.Fields

       

        Set objEmail = CreateObject("CDO.Message")

        objEmail.Configuration.Fields.Item _

        ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2

       

        objEmail.Configuration.Fields.Item _

        ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = _

        "10.3.1.35"  '

       

        objEmail.Configuration.Fields.Item _

        ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25

       

        objEmail.Configuration.Fields.Update

       

        appname6 = "E:\Qlik2Finance\Extraction\HOUSING_FINANCE\Alert\Export\DailySales\Daily Sales_29-Aug-2013.xls"                        

       

        'if (getVariable("BRANCH_COUNT"))>0 then

            'objEmail.AddAttachment appname6

        'else           

        'appname2="E:\Qlik2Finance\Extraction\HOUSING_FINANCE\Alert\Export\Disbursement\Branchwise_No_Disbursement\Branchwise_Amount_Disbursed.xls"    

        'objEmail.AddAttachment appname2

        'end if   

         objEmail.AddAttachment appname6

       

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

         ' msgbox objSelected.item(i).Text

              strMailTo = objSelected.item(i).Text   

              'objEmail.To= ""

            objEmail.To = strMailTo 

            objEmail.From = ""

            objEmail.CC = ""

            objEmail.Subject ="Daily Sales Report"

            objEmail.TextBody = "Dear All,"&chr(13)&chr(13)&"Please Find Attached Daily Sales Report as on "&getVariable("CurrentDate")&chr(13)&chr(13)&"Regards,"&chr(10)&"QlikView Admin"&chr(13)&chr(13)&"Note: This is an auto generated mail from QlikView.Please don't reply of this mail "

            objEmail.Send   

               

               

        next       

       

        Set objFlds = Nothing

        Set objConf = Nothing

        Set objEmail = Nothing

       

    end if

   

end function

2 Replies
vikasmahajan

Please study the following QVW this is will help you to send XLSx file in macros.

Good Luck

Vikas

Hope this resolve your issue.
If the issue is solved please mark the answer with Accept as Solution & like it.
If you want to go quickly, go alone. If you want to go far, go together.
Kushal_Chawda
Author

Hi,

I will study this macro & will let you know