Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
gardenierbi
Contributor

Send mail (Windows 2008 Server)

Before Windows 2008 we used the CDOSYS library for sending mail with a macro. Windows 2008 doesn't have this library, we should use the System.Net.Mail namespace from the .NET Framework (see: http://hosting.intermedia.net/support/kb/default.asp?id=1579). So instead coding this:

Set objEmail = CreateObject("CDO.Message")

We should coding this:

%@ Import Namespace="System.Net.Mail"%

How can we do this with QlikView?

I've already searched for an example on the Community but I can't find any. Who has a working example for mailing with a macro from a Windows 2008 Server 64bit environment?

1 Solution

Accepted Solutions
fosuzuki
Valued Contributor II

Re: Send mail (Windows 2008 Server)

Hi,

I have one app working in Windows 2008 Server. It works both when triggering it locally in the server and when the user triggers it wia IE Plugin. I use the following code in a macro (some parts are commented out because my environment doesn't need):


' Object creation

Set objMsg = CreateObject("CDO.Message")

Set msgConf = CreateObject("CDO.Configuration")

Set myMail=CreateObject("CDO.Message")

'==This section provides the configuration information for the remote SMTP server.

' Server Configuration

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

'Name or IP of Remote SMTP Server

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

'Server port (typically 25)

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

''Use SSL for the connection (False or True)

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

''Type of authentication, NONE, Basic (Base64 encoded), NTLM

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

''Your UserID on the SMTP server

'msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "YourEmail"

''Your password on the SMTP server

'msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "YourPassword"

''Connection Timeout in seconds (the maximum time CDO will try to establish a connection to the SMTP server)

'msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60

msgConf.Fields.Update

' Email

objMsg.Sender = ""

objMsg.From = "email@email.com"

objMsg.To = sEmailTo

objMsg.Subject = sEmailSubject

objMsg.TextBody = sEmailTextBody

Set objMsg.Configuration = msgConf

' Send

objMsg.Send

' Clear

Set objMsg = nothing

Set msgConf = nothing

As far as I know, the server didn't receive any addidional configuration for this to work...

Hope this helps you.

Regards,

Fernando

1 Reply
fosuzuki
Valued Contributor II

Re: Send mail (Windows 2008 Server)

Hi,

I have one app working in Windows 2008 Server. It works both when triggering it locally in the server and when the user triggers it wia IE Plugin. I use the following code in a macro (some parts are commented out because my environment doesn't need):


' Object creation

Set objMsg = CreateObject("CDO.Message")

Set msgConf = CreateObject("CDO.Configuration")

Set myMail=CreateObject("CDO.Message")

'==This section provides the configuration information for the remote SMTP server.

' Server Configuration

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

'Name or IP of Remote SMTP Server

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

'Server port (typically 25)

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

''Use SSL for the connection (False or True)

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

''Type of authentication, NONE, Basic (Base64 encoded), NTLM

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

''Your UserID on the SMTP server

'msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "YourEmail"

''Your password on the SMTP server

'msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "YourPassword"

''Connection Timeout in seconds (the maximum time CDO will try to establish a connection to the SMTP server)

'msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60

msgConf.Fields.Update

' Email

objMsg.Sender = ""

objMsg.From = "email@email.com"

objMsg.To = sEmailTo

objMsg.Subject = sEmailSubject

objMsg.TextBody = sEmailTextBody

Set objMsg.Configuration = msgConf

' Send

objMsg.Send

' Clear

Set objMsg = nothing

Set msgConf = nothing

As far as I know, the server didn't receive any addidional configuration for this to work...

Hope this helps you.

Regards,

Fernando

Community Browser