home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a108 / 6.ddi / SAMPLES / MAILMENU / SENDMAIL.PRG < prev    next >
Encoding:
Text File  |  1993-09-09  |  2.5 KB  |  113 lines

  1. * sendmail.prg
  2. * This program is called from the Send Mail
  3. * menu item. It displays a dialog to send a
  4. * message after prompting for and validating
  5. * a mail name/alias.
  6.  
  7. PRIVATE tonames,subject,notetext,islogon,newname,oldtalk,retval
  8.  
  9. IF SET("TALK") = "ON"
  10.     SET TALK OFF
  11.     m.oldtalk= "ON"
  12. ELSE
  13.     m.oldtalk= "OFF"
  14. ENDIF
  15.  
  16. islogon=.F.
  17. DO CASE
  18.     CASE TYPE('mailsession')#'N'
  19.         PUBLIC mailsession
  20.         mailsession = 0
  21.         mailsession=mapilib('LOGON')
  22.     CASE m.mailsession=0
  23.         mailsession=mapilib('LOGON')
  24.     OTHERWISE
  25.         islogon=.T.
  26. ENDCASE
  27.  
  28. IF m.mailsession=0  &&failed to logon
  29.     SET TALK &oldtalk
  30.     RETURN
  31. ENDIF
  32.  
  33. m.subject=SPACE(50)
  34. m.notetext=""
  35. m.okbtn=1
  36. m.newname=SPACE(30)
  37.  
  38. * Call screen to display prompt for entering
  39. * name to lookup. It is then checked in the
  40. * resolve name MAPI function.
  41. DO getname.spr
  42. IF m.okbtn=2
  43.     SET TALK &oldtalk
  44.     RETURN
  45. ENDIF
  46. IF !mapilib('resolve',m.mailsession,newname)
  47.     SET TALK &oldtalk
  48.     RETURN
  49. ENDIF
  50.  
  51. * Set field in screen.
  52. m.tonames=ALLT(mapirecip.name)
  53.  
  54. * Call FoxPro screen
  55. DO sendmail.spr
  56.  
  57. * Now cleanup after exiting screen.
  58. IF !islogon
  59.     =mapilib('LOGOFF',m.mailsession)
  60.     mailsession = 0
  61. ENDIF
  62. SET TALK &oldtalk
  63.  
  64.  
  65.  
  66. *!*********************************************************************
  67. *!
  68. *!      FUNCTION: btnval
  69. *!
  70. *!*********************************************************************
  71. * This procedure handles the MAPI buttons. The user can either
  72. * send a message or only save it in his/her inbox.
  73. FUNCTION btnval
  74.     IF m.btn#3
  75.         =mapilib('newcursor','mapiFile')
  76.         =mapilib('newcursor','mapiMesg')
  77.         INSERT INTO mapimesg VALUES(0,m.subject,m.notetext,'IPM.',;
  78.             mapilib('getdate'),'',0,RECCOUNT('mapiRecip'),0)
  79.         IF m.btn=1
  80.             retval=mapilib("sendmail",m.mailsession,"mapiMesg","mapiRecip","mapiFile",0)
  81.         ELSE
  82.             retval=mapilib("savenote",m.mailsession)
  83.         ENDIF
  84.         IF !EMPTY(m.retval)
  85.             WAIT WINDOW 'Message saved/sent successfully...' TIMEOUT 1
  86.         ENDIF
  87.         USE IN mapimesg
  88.         USE IN mapifile
  89.     ENDIF
  90.     USE IN mapirecip
  91.     CLEAR READ
  92.     RETURN
  93.  
  94.  
  95.     *!*********************************************************************
  96.     *!
  97.     *!      FUNCTION: getname
  98.     *!
  99.     *!*********************************************************************
  100.     * This function calls the address both to change the name of the
  101.     * message recipient(s). This differs from the original address which
  102.     * is checked through the resolve dialog.
  103. FUNCTION getname
  104.     IF !mapilib("addbook",m.mailsession,1)
  105.         RETURN
  106.     ENDIF
  107.     m.tonames=''
  108.     SCAN
  109.         m.tonames=m.tonames+ALLT(mapirecip.name)+'..'
  110.     ENDSCAN
  111.     SHOW GETS
  112.     RETURN
  113.