2 Replies Latest reply: Dec 7, 2017 2:11 PM by Braham Edwards RSS

    Sending emails from Qlikview

    Braham Edwards

      Evening all

      I was hoping that some of the more tech savvy members would be able to assist or point me in the right direction.


      I want to be able to send an email with a .pdf report attached to a selection of users on a daily basis. I have developed the Qlikview app that writes out the .pdf and can mail the report from my desktop version when not linked to the company network. I got the code from the forum. It uses the gmail smtp server to send the mail.


      Once I try to run Qlikview from our warehouse server it returns the message 'The transport failed to connect to the server'. When running on the company server I use the company SMTP server and not the gmail server.


      What is strange is that I can send an email using Powershell. I use the same parameters in my Qlikview model as Powershell. I have worked with our sever engineer to try to get it to work without success. It seems to me to be a setting on the server/virus protection/mail server. In order to get the mail to send they setup the mail server to allow it to relay messages. The code below is what I use.


      SUB SendMail
      Dim objEmail
      Const cdoSendUsingPort = 2 ' Send the message using SMTP
      Const cdoBasicAuth = 1 ' Clear-text authentication Const
      cdoTimeout = 60 ' Timeout for SMTP in seconds 
      mailServer = "relay.enterpriseoutsourcing.co.za"
      SMTPport = 25
      mailusername = "Qlikview@universal.co.za"
      mailpassword = ""
      mailto = "braham@tiscali.co.za; Braham.Edwards@universal.co.za"
      mailSubject = "Report 01"
      mailBody = "This is the email body" 
      Set objEmail = CreateObject("CDO.Message")
      Set objConf = objEmail.Configuration
      Set objFlds = objConf.Fields
      With objFlds
      .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPort
      .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = mailServer
      .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = SMTPport
      .Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
      .Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = cdoTimeout
      .Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoBasicAuth
      .Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = mailusername
      .Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = mailpassword
      End With
      objEmail.To = mailto
      objEmail.From = mailusername
      objEmail.Subject = mailSubject
      objEmail.TextBody = mailBody
      objEmail.AddAttachment "C:\QlikView Printing.pdf"
      Set objFlds = Nothing
      Set objConf = Nothing
      Set objEmail = Nothing

      END SUB


      The sending fails on the objEmail.Send statement


      Some input would be appreciated, especially if some advise on possible server settings that need to be enabled.




      Braham Edwards