Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
braham
Creator
Creator

Sending emails from Qlikview

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
.Update
End With
objEmail.To = mailto
objEmail.From = mailusername
objEmail.Subject = mailSubject
objEmail.TextBody = mailBody
objEmail.AddAttachment "C:\QlikView Printing.pdf"
objEmail.Send 
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.

Regards

Braham Edwards

2 Replies
krishna20
Specialist II
Specialist II

Hi Edwards,

Please refer the below thread to configure users in qvw.

QlikView Scheduled & Automated Reports – Sending Excel via Email

braham
Creator
Creator
Author

Hi Kalyan

I did look at the post you mentioned, but it is sent from a gmail SMTP server. My script works from a gmail account, but not from our exchange server.

Braham