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

Script for Exporting and Sending email

Hi Everybody,

Please help me the script to export the Qlikview documents into Excell/PDF file and the script to send email in Qlikview environment.

Many thanks,

Tai.

85 Replies
Not applicable
Author

Hi JochenAndries

I am working on sending email via macro.

Please go through the following code, the execution of code get stopped at objEmail.Send and looking forward for the solution  for this issue

sub irf17

zendDagrapport()

end sub

'================================================

function zendDagrapport()

Dim objEmail

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

Const SMTPServer =  "smtp.gmail.com"

Const SMTPPort = 465 ' Port number for SMTP

Const SMTPTimeout = 60 ' Timeout for SMTP in seconds

Const user = "ghori.irf@gmail.com"

Const psw = "123456"

'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/smtpauthenticate") = codBasic

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

.Item("http://schemas.microsoft.com/cdo/configuration/sendusername")= user

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

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

.Update

'---------------------------------------------------------------------

End With

objEmail.To = "irfanplucky@gmail.com" 'Email Recipient

objEmail.From = "ghori.irf@gmail.com" 'Email Sender

objEmail.Subject = "Test_Subject" ' Subject

objEmail.TextBody = "Test" 'Text Body

'for each item in reportFiles ' Add selected reports to mail

'                              if item <>"" then

'                                        objEmail.AddAttachment item

'                              end if

'          next

'objEmail.AddAttachment "link to file" ' Attachement

msgbox("Before Send")

objEmail.Send

msgbox("After Send")

Set objFlds = Nothing

Set objConf = Nothing

Set objEmail = Nothing

msgbox ("Test Mail Sent")

end function



Not applicable
Author

Can you provide me the macros for Script for Exporting and Sending email

Not applicable
Author

hey jochen, i just tried your code to send mail, but it stops at objEmail.Send. Can you provide some resolutions to this or what might be the possible cause..in module editor i have set the security settings to system...

br

Not applicable
Author

hi i have done some changes and now while executing the code i am getting the below error

"The server rejected the sender address.The server response was : 530 5.7.1 Client was not authenticated"

Can anyone provide some help on this.....

Anonymous
Not applicable
Author

Ronny

This is the code thats working for me:

_________________________________________________________

sub SENDMAIL()
Dim objEmail
Const cdoSendUsingPort = 2 ' enviar mensaje usando SMTP
Const cdoAnonymous = 0 'Sin autentificar
Const cdoBasic = 1 'basic (clear-text) autentificacion
Const cdoNTLM = 2 'NTLM
'SMTPServer = "IP del servidor mail"
SMTPServer = "10.25.51.31"
Const SMTPPort = 25 ' Numero de puerto para SMTP
Const SMTPTimeout = 60 ' Timeout para el SMTP en segundos
'Sending mail
Set objEmail = CreateObject("CDO.Message")
Set objConf = objEmail.Configuration
Set objFlds = objConf.Fields
With objFlds
'---------------------------------------------------------------------
' Detalles del servidor SMTP
.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 =

"x@domain.com"  'Email Receptor
objEmail.From = "x@domain.com" 'Email Envia
objEmail.Subject = "Anything" ' Asunto
objEmail.TextBody = "Anything"
objEmail.AddAttachment "c:\PDF\any_document.pdf" ' Adjunto
objEmail.Send
Set objFlds = Nothing
Set objConf = Nothing
Set objEmail = Nothing
end sub

_________________________________________________________

I dont have any problem with it.

Regards.

Anonymous
Not applicable
Author

jaguilera, is this code working under 64bit ?

jonathan

Not applicable
Author

Hi all,

I installed the Bull Zip pdf Writer.

When I tried to test the code of macro, I received the error.

Please help me out for the same.

Capture.PNG

Not applicable
Author

Please help , why this error persists while I have installed Bull zip pdf writer!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Capture.PNG

Not applicable
Author

Is it a 32bit machine or 64bit ? (= does NOT work with 64bit)

Please set both your Security-settings to SYSTEM (=NOT safe mode)

Anonymous
Not applicable
Author

JochenAndries,jonbroughavone ...only works for me in a 32 bits machine.