Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
gardenierbi
Creator II
Creator II

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
Partner - Specialist III
Partner - Specialist III

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

View solution in original post

1 Reply
fosuzuki
Partner - Specialist III
Partner - Specialist III

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