Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Macro to send e-mail

hi everyone,

I am looking for macro to send e-mail on daily basis from my qlikview document.

welcome all suggestion

Thanks in advance.

3 Replies
Anonymous
Not applicable
Author

Hi,

    Try this

Sub SendMail(toMailID, attachmentPath)

    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 = "199.199.199.199" Your SMTP Server

    Const SMTPPort = 25                 ' Port number for SMTP

    Const SMTPTimeout = 60              ' Timeout for SMTP in seconds

    '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 = toMailID        'Email Recipient

    objEmail.From = "yourMail@gmail"                        'Email Sender

    objEmail.Subject = "**Subject**"                        ' Subject

    'objEmail.TextBody = "some text in the body of the mail"        'Text Body         

    objEmail.AddAttachment   attachmentPath    ' Attachement

    objEmail.Send

    Set objFlds = Nothing

    Set objConf = Nothing

    Set objEmail = Nothing

End Sub

Not applicable
Author

password authentication is not required in this?

SMTP server and port no. is of sender or recipient?

Anonymous
Not applicable
Author

Hi vijit,

     SMTP server and port no of Sender only.