SEE Example / Beispielprogramm

PROGRAM qtDRIVER
   USE qt_seeMail   ! Module for accessing SEE functions,
                  ! as supplied by QT software
                  !for Salford FTN95
   IMPLICIT NONE
   CHARACTER*64 SmtpHostName
   CHARACTER*64 YourEmailAddr
   CHARACTER*64 SendTo
   CHARACTER*64 Subject
   CHARACTER*64 Message
   INTEGER*4 Code
   INTEGER*4 Counter

! *** IMPORTANT **********************************
! *** Edit these next 3 lines with your SMTP server name
! *** and email addresses. See Users Manual (SEE4F_U.TXT)
! ***********************************************
SmtpHostName = ‘smtp_host_name’ // CHAR(0)
YourEmailAddr = ‘your_email_address’ // CHAR(0)
SendTo = ‘receipients_email_address’ // CHAR(0)

! *** define remaining email parameters
Subject = ‘qtDriver Test’ // CHAR(0)
Message = ‘Mailed from qtDriver program!’ // CHAR(0)

! *** connect to SMTP server
WRITE(*,*) ‘Calling seeConnectTo()...’
! ReplyTo header
Code = seeConnectToNoReply(SmtpHostName,             &
                  YourEmailAddr, 0 )
Code = Connect(SmtpHostName, YourEmailAddr, 0 )
IF(Code .LT. 0) THEN
   WRITE(*,*) ‘seeConnectTo returns error ‘, Code
   CALL ErrorExit
END IF

! *** disable AUTO CALL
Code = seeIntegerParam( SEE_AUTO_CALL_DRIVER, 0 )
! *** setup to send email
WRITE(*,*) ‘Calling seeSendEmail()...’
Code = seeSendEmailNoAttachBCCC(SendTo, 0, 0, Subject, &
                  Message, 0 )      ! no BC, CC, attachment
IF(Code .LT. 0) THEN
   WRITE(*,*) ‘seeSendMail returns error ‘, Code
   CALL ErrorExit
END IF

! *** call driver to send email
Counter = 0
100 Code = seeDriver()
! *** error ?
IF(Code .LT. 0) THEN
   WRITE(*,*) ‘seeDriver returns error ‘, Code
   CALL ErrorExit
END IF
! *** good return code ?
IF (Code .GT. 0) THEN
! *** don’t count wait states
   IF (Code .NE. 9999) THEN
   ! *** print dot every 100’th call
      Counter = Counter + 1
      IF (Counter .EQ. 100) THEN  
         WRITE(*,*) ‘.’
         Counter = 0
      END IF
   END IF
   GOTO 100
END IF
! *** Code must be 0 (Driver is done)
WRITE(*,*) ‘Email sent’

!     *** enable AUTO CALL & close
Code = seeIntegerParam( SEE_AUTO_CALL_DRIVER, 1 )
Code = seeClose()

PAUSE ‘Driver - Test program to terminate.’
END


SUBROUTINE ErrorExit
! Error exit subroutine
USE qt_seeMail
CHARACTER*64 Buffer
INTEGER*4 I, Code

!   clear Buffer
DO I = 1, 64
   Buffer = ‘ ‘
ENDDO

!   get error text into Buffer & print message
Code = seeErrorText( Code, Buffer, 64)
WRITE(*,*) Buffer
Code = seeClose()
PAUSE ‘Driver - Test program to terminate.’
END