Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

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.
Not applicable

How to send a mail through macro?

Hi All,

I want to know How to send a mail through macro?

I have write the script like below , but it is not working

function sendMailTest()

          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 = "mail.myserver.net"

          Const SMTPPort = 25                             ' Port number for SMTP

          Const SMTPTimeout = 60                          ' Timeout for SMTP in seconds

// Till here Script is working

// From here the script is not working

          '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/smtpusessl") = False

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

                       .Update

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

          End With

          objEmail.To = "maneeswaran.kannan@Myserver.com"

          objEmail.From = "kabilan.kumarasamy@Myserver.com"

          objEmail.Subject = "test"

          objEmail.TextBody = "message de test"

          objEmail.Send

          Set objFlds = Nothing

          Set objConf = Nothing

          Set objEmail = Nothing

          msgbox ("Test Mail Sent")

end function

Please help me on this issue..

Thanks In advance...

Regards,

Kabilan K

2 Replies
Not applicable

Re: How to send a mail through macro?

Try this:

sub Email


Set myApp = CreateObject ("Outlook.Application")

Set myMessage = myApp.CreateItem(olMailItem)

myMessage.BodyFormat = 3 'Outlook.OlBodyFormat.olFormatRichText



myMessage.To = InputBox("Enter email address in johnsmith@mail.com format","Email Address")

myMessage.Subject = "Test"

myMessage.Body = "Test Email.................................."



myMessage.Send

MsgBox("Test Email Sent")



Set myMessage = Nothing

Set myApp = Nothing

Set myInspector = Nothing

Set myDoc = Nothing



end sub



Not applicable

Re: How to send a mail through macro?

Hi,

In your code also not working till this script Set myApp = CreateObject ("Outlook.Application")

Regards,

Kabilan K.

Community Browser