Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
smilingjohn
Specialist
Specialist

Sending an Email

HI All

I   have chart in my dashboard and some reports , I want to send the report  by email in qlikview .

Can someone suggest me how do we do this ?

Iam Using the below scrip but to its not working , Can some one thriught some light on this :

Error: Could not connect to Server

Sub SendReport

ActiveDocument.Sheets("SH01").Activate 'edit the sheet 

'ActiveDocument.reload

set objExcel=ActiveDocument.GetSheetObject("CH01") 'edit the sheet object

strDate = Year(Date()) &"-"& month(date()) &"-"& Day(Date()) 

filepath="D:\Excel_"&strDate&".xls"   'edit the location of file

objExcel.ExportBiff filepath

ActiveDocument.GetApplication.Sleep 5000

SendGMail

ActiveDocument.Save

set objExcel=nothing

set strDate=nothing

set filepath=nothing

End Sub

Sub SendGMail()

MsgBox "Report Exported Successfully"

strDate = Year(Date()) &"-"& month(date()) &"-"& Day(Date())  

filepath="D:\Excel_"&strDate&".xls"

Set objMsg = CreateObject("CDO.Message")

Set msgConf = CreateObject("CDO.Configuration")

'Server Configuration

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

msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "spzexch.bsil.com "

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

msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1

msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "mohammad.benni@bsil.com" 'type your mail id

msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "123" 'Type your acccount Password

msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = 1

msgConf.Fields.Update

'End With

objMsg.To = "mohammad.benni@bsil.com" ' type to mail id

objMsg.From = "mohammad.benni@bsil.com" 'type from mail id

objMsg.Subject = "Test mail"

objMsg.HTMLBody = "QlikView Test Mail"

'objMsg.AddAttachment "D:\Image.jpg"

objMsg.AddAttachment   filepath    ' Attachement object

objMsg.Sender = "Mr. Name"

Set objMsg.Configuration = msgConf

' Send

objMsg.Send

Msgbox("Email Sent Successfully")

' Clear

Set objMsg = nothing

Set msgConf = nothing

End Sub

Regards

Siraj

4 Replies
MK_QSL
MVP
MVP

smilingjohn
Specialist
Specialist
Author

I went to the link u suggested me , but after implemeting it is giving the below error

The message could not be sent to the SMTP server. The transport error code was 0x80040217. The server response was not available

  objMsg.Send    

svenkita
Creator II
Creator II

Macro...

Attaching a sample file hope this helps

jagan
Luminary Alumni
Luminary Alumni

Hi,

You need to configure this settings, check with your admin team and change the setting in the script

'Server Configuration

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

msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"

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

msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1

msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "500vikas@gmail.com"

msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "**********" 'Type your acccount Password

msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = 1

msgConf.Fields.Update

'End With

objMsg.To = "Sender Mail ID"

objMsg.From = "Xyzz@gmail.com"

objMsg.Subject = "Test mail"

objMsg.HTMLBody = "QlikView Test Mail"

'objMsg.AddAttachment "D:\Image.jpg"

objMsg.AddAttachment   filepath    ' Attachement

objMsg.Sender = "Mr. Name"

Set objMsg.Configuration = msgConf