home *** CD-ROM | disk | FTP | other *** search
/ Asymetrix Demo / Asymetrix.iso / prg / mtb30 / samples / mapi.tbk (.txt) < prev    next >
Encoding:
Asymetrix ToolBook File  |  1994-07-11  |  84.7 KB  |  1,653 lines

  1. Counting Messages
  2. Checking For Unread Mail
  3. Using MAPI
  4. Using MAPI+
  5. Microsoft's Messaging Application Programming Interface (MAPI) is a set of high level DLL functions that are the foundation of electronic mail in Windows. Applications use these functions to create, manipulate, transfer, and store messages.
  6. The scripts and examples in this book demonstrate how to access MAPI from ToolBook, but are not intended to teach you MAPI. It is assumed that you are familiar with and have documentation for MAPI.
  7. The handlers which directly access the MAPI functions are all found in the script of this book.s which applications used to create, manipulate, transfer, and store messages. Most of these functions are exported from MAPI.DLL and form the basis for electronic mail in Windows.
  8. The scripts and examples in this book demonstrate how to access MAPI from ToolBook, but are not intended to teach MAPI to the user. In fact. it is assumed that user is familiar with and has documentation for MAPI.
  9. The handlers which directly access the MAPI functions are all found in the book script.
  10. Sending Messages
  11. Sending Messages
  12. Sending Messages5
  13. The example below illustrates how to send a message without using the MAPI dialog box. Fill in the fields below and click the button when you are ready to send the message..the message.
  14. Send Message
  15. .&+    +E
  16. .&+    +E
  17. }str_sent
  18. getAddress
  19. sendMessage
  20. s_MAPIError
  21. str_notSent
  22. buttonClick
  23. buttonClick
  24. 4s_MAPIError
  25. there 
  26. no recipient supplied
  27.         -- call up 
  28. 6 Address Book
  29. getAddress()
  30.         -- 
  31. we don't 
  32. address we won't 
  33. a message
  34.         -- fill 
  35.  appropriate 
  36. sendMessage(
  37. "sub",
  38. "body")
  39.     -- confirm whether 
  40.  was sent
  41. str_notSent()&&
  42. str_sent()
  43. &Send Message
  44. Bob N.
  45. We're almost there now.
  46. Don't blow it!
  47. Subject:
  48. Text:
  49. Submit Reports
  50. Receive Reports
  51. Receive Reports
  52. View New
  53. uupdateMessages
  54. buttonClick
  55. buttonClick
  56.     -- scan incoming mail 
  57. problem reports 
  58. setup the 
  59.     -- (
  60. message 
  61. handled 
  62. updateMessages 
  63. &View New
  64. delete
  65. [4deleteMessage
  66. uupdateMessages
  67. str_OK
  68. s_MsgHandles
  69. s_MsgNum
  70. s_MAPIError
  71. Rstr_notDelete
  72. buttonClick
  73. buttonClick
  74. 4s_MsgNum,s_MsgHandles,s_MAPIError
  75.     -- delete the current message
  76. deleteMessage(
  77. <> str_OK()
  78. str_notDelete()&&
  79.     -- refresh 
  80. [ list 
  81.     -- (
  82. handled 
  83. updateMessages 
  84. D&elete
  85. Previous
  86. 8parseMsgText
  87. s_MsgNum
  88. buttonClick
  89. buttonClick
  90. 4s_MsgNum
  91. mail message
  92. disable 
  93. G = 1
  94.         enabled 
  95. B"Next" = 
  96.     -- fill 
  97. ~fields 
  98.     -- (
  99. handled 
  100. parseMsgText
  101. &Previous
  102. Previous
  103. 8parseMsgText
  104. s_MsgCount
  105. s_MsgNum
  106. buttonClick
  107. buttonClick
  108. 4s_MsgNum,s_MsgCount
  109. tmessage
  110. , disable 
  111.         enabled 
  112. B"Previous" = 
  113.     -- fill 
  114. fields 
  115.     -- (
  116. handled 
  117. parseMsgText
  118. &Next
  119. Submit Reports
  120. Submit Reports
  121. buttonClick
  122. buttonClick
  123. "Submit Reports"
  124. &Submit Reports
  125. examples
  126. buttonClick
  127. buttonClick
  128. the example 
  129. Fclose 
  130. isOpen 
  131. "examples"
  132. &Done
  133. toLabel
  134. From:ss:
  135. problem
  136. Department
  137. address
  138. msgnum
  139. No messagesf 10
  140. toLabel
  141. Department:
  142. office
  143. phone
  144. toLabel
  145. Problem Area:
  146. toLabel
  147. Phone::::::::
  148. toLabel
  149. Office: Area:
  150. toLabel
  151. Description of problem:
  152. description
  153. toLabel
  154. Sent:ss:
  155. timestamp
  156. Example: Problem Reports
  157. Verifying Names
  158. -- a notify handler was used 
  159. the address 
  160. you enter 
  161. Verifying Names
  162. Verifying Names
  163. Click Check Names to get the full names of those displayed in the upper field and place them in the lower field.
  164. If a name is ambiguous, MAPI displays a dialog box that allows the user to choose the correct name.opriate... field. 
  165. If a name is ambiguous, MAPI will display a dialog allowing the user to choose which name is appropriate.
  166. Check Names
  167. 1,    #>
  168. checkNames
  169. partial
  170. s_MAPIError
  171. str_notResolved
  172. buttonClick
  173. buttonClick
  174. 4s_MAPIError
  175. a list 
  176. verified names 
  177. checkNames(
  178. "partial")
  179. error condition
  180. "full" = 
  181.         -- 
  182. some 
  183. hcould 
  184. xbe resolved:
  185.         -- the 
  186. value 
  187.         --    
  188. those that 
  189.         -- 
  190.         --    
  191. ,were 
  192. str_notResolved()&
  193. &Check Names
  194. partial
  195. Tom,Dick,Harry
  196. enterPage
  197. notifybefore 
  198. = "Tom,Dick,Harry"
  199. Tom,Dick,Harryelda
  200. enterPage
  201. notifybefore 
  202. enterPage
  203. examples
  204. Linking to MAPI.DLL
  205. Sending Messages
  206. Checking For Unread Mail
  207. -- notify handlers were used 
  208. [the fields 
  209. -- you enter 
  210. Checking For Unread Mail
  211. Checking For Unread Mail
  212. The script of this button steps through the messages in your incoming mail folder, looking for unread messages. The sender and subject of each unread message are placed in the fields below.. fields.
  213. Check for Unread Mail
  214. eck for Unread Mail
  215. Messages
  216. text area
  217. textScrolled
  218. buttonUp
  219. the fields together
  220. -- There are three 
  221. order 
  222. these 
  223. -- smoothly, 
  224. filled 
  225. fdummy 
  226. which has 
  227. -- same 
  228. other 
  229. . Only 
  230. b. When 
  231. scrolled, 
  232. 2two 
  233. -- If there were only 
  234. bar would 
  235. textScrolled 
  236. oselectedtextlines = 
  237. scrollbar
  238. enterPage
  239. notifybefore 
  240. Subject
  241. enterPage
  242. notifybefore 
  243. enterPage
  244. notifybefore 
  245. From:
  246. Subject:
  247. enterPage
  248. &Check for Unread Mail
  249. functions
  250. linkdll "mapi.dll"
  251.    DWORD MAPILogoff (DWORD, DWORD, DWORD, DWORD)
  252.    DWORD MAPILogon (DWORD, STRING, STRING, DWORD, DWORD, POINTER)
  253.    DWORD MAPIFindNext (DWORD, DWORD, DWORD, POINTER, DWORD, DWORD, \
  254.                                         POINTER)
  255.    DWORD MAPIFreeBuffer (POINTER)
  256.    DWORD MAPISendMail (DWORD, DWORD, POINTER, DWORD, DWORD)
  257.    DWORD MAPIReadMail (DWORD, DWORD, STRING, DWORD, DWORD, POINTER)
  258.    DWORD MAPIResolveName (DWORD, DWORD, STRING, DWORD, DWORD,  \
  259.                                               POINTER)        
  260.    DWORD MAPISendDocuments (DWORD, STRING, STRING, STRING, DWORD)    
  261.    DWORD MAPIAddress (DWORD, DWORD, STRING, DWORD, STRING, DWORD, \
  262.                                       DWORD, DWORD, DWORD, POINTER, POINTER)
  263.    DWORD MAPIDeleteMail (DWORD,DWORD,STRING,DWORD,DWORD)
  264. end linkDLL,STRING,DWORD,DWORD)
  265. end linkDLL
  266. buttonClick
  267. buttonClick
  268. isOpen 
  269. "link"
  270.         close 
  271. functions
  272. buttonClick
  273. Bcopies 
  274. clipboard
  275. buttonClick
  276.     -- place 
  277. "functions"
  278.     -- take 
  279. B"ok"
  280. &Copy to Clipboard
  281. &File
  282. &Open...    Ctrl+O
  283. &Save    Ctrl+S
  284. Save &As...
  285. saveas
  286. Print Set&up...
  287. printsetup
  288. &Print Pages...    Ctrl+P
  289. printpages
  290. &Run...
  291. E&xit    Alt+F4
  292. &Edit
  293. &Undo    Ctrl+Z
  294. Cu&t    Ctrl+X
  295. &Copy    Ctrl+C
  296. &Paste    Ctrl+V
  297. paste
  298. C&lear    Del
  299. clear
  300. Aut&hor    F3
  301. author
  302. &Page
  303. &Next    Alt+Right
  304. &Previous    Alt+Left
  305. previous
  306. &Menu    Alt+Up
  307. first
  308. &Help
  309. &Contents    F1
  310. contents
  311. g: fs2/vo
  312. Linking to MAPI.DLL
  313. Linking to MAPI.DLL
  314. The functions for handling messages in Windows are exported from MAPI.DLL. Click View DLL Functions to see the way these functions are prototyped in OpenScript.ped in OpenScript.
  315. buttonClick
  316. buttonClick
  317. display a 
  318. which 
  319.     -- linking information
  320. &View DLL Functions
  321. Composing Mail
  322. Composing Mail
  323. Composing Mail
  324. Click Compose Message to open the MAPI dialog box you use to compose and send a message.
  325. Click Attach a File if you want to attach a file to the message you compose.....se buttons bring up the MAPI dialog box allowing you to compose and send a message.
  326. The second button attaches a file to the message that you compose.
  327. Compose Message
  328. s_MAPIError
  329. ucomposeMessage
  330. buttonClick
  331. buttonClick
  332. 4s_MAPIError
  333.     -- compose a message
  334. composeMessage()
  335. returned - 
  336. error condition
  337. k <> 
  338. &Compose Message
  339. Attach a File
  340. filename
  341. ZsendFile
  342. s_MAPIerror
  343. buttonClick
  344. buttonClick
  345. 4s_MAPIerror
  346.     -- compose a message 
  347. attached file
  348. sendFile(
  349. "filename")
  350. returned - 
  351. b condition
  352. s_MAPIError <> 
  353. &Attach a File
  354. filename
  355. enterPage
  356. notifyBefore 
  357. C:\JX\MAPI\MAPI.TBKKKKKKKBK
  358. enterPage
  359. Composing Mail
  360. Looking up Addresses
  361. Verifying Names
  362. Counting Messages
  363. Counting Messages
  364. Counting Messages
  365. Click the appropriate button below to count the messages in your incoming mail folder.by stepping through them one at a time.il folder by stepping through them one at a time. This first counts all messages, and the seconds counts only unread messages.
  366. Count All Messages
  367. .&+    +E
  368. .&+    +E
  369. FALSE
  370. str_msgCountAll
  371. l'getNextMsgID
  372. 1RgetFirstMsgID
  373. buttonClick
  374. buttonClick
  375. ZLONG count
  376. the ID 
  377. message (read 
  378. unread)
  379. getFirstMsgID(FALSE)
  380. found
  381.         -- 
  382. getNextMsgID(
  383. str_msgCountAll(
  384. Count &All Messages
  385. Count Unread Messages
  386. .&+    +E
  387. .&+    +E
  388. l'getNextMsgID
  389. Dstr_msgCountUnread
  390. 1RgetFirstMsgID
  391. buttonClick
  392. buttonClick
  393. ZLONG count
  394. the ID 
  395. message (read 
  396. unread)
  397. getFirstMsgID(TRUE)
  398. found
  399.         -- 
  400. getNextMsgID(
  401. str_msgCountUnread(
  402. Count &Unread Messages
  403. Arial
  404. Arial
  405. Arial
  406. Arial
  407.  Sans Serif
  408. Arial
  409. Arial
  410. MS Sans Serif
  411. Page id 23
  412. examples
  413. Page "Submit Reports"
  414. MAPI Tutorial
  415. examples
  416. Submit Reports
  417. department
  418. Salestingnt
  419. Development
  420. Executive
  421. Finance
  422. Marketing
  423. Sales
  424. Technical Support
  425. Testings
  426. problem
  427. Hardware Problemtion
  428. E-Mail
  429. Hardware Installation
  430. Hardware Problem
  431. Network
  432. Other
  433. Phones
  434. Printers
  435. Software Installation
  436. Software Problem
  437. office
  438. phone
  439. x3434
  440. description
  441. My machine won't boot right. The disk keeps running and running but nothing happens.
  442. Change Address
  443. nameList
  444. getAddress
  445. buttonClick
  446. buttonClick
  447.     -- call up the Addressbook dialog 
  448. a list 
  449. names
  450.     nameList = getAddress()
  451. namelist 
  452. &Change Address
  453. Receive Reports
  454. Receive Reports
  455. buttonClick
  456. buttonClick
  457. "Receive Reports"
  458. ceive Reports
  459. examples
  460. buttonClick
  461. buttonClick
  462. the example 
  463. Fclose 
  464. isOpen 
  465. "examples"
  466. &Done
  467. Jim Geldmacher
  468. str_problemRep
  469. enterPage
  470. subject 
  471. standard 
  472. reports
  473. notifybefore 
  474. = str_problemRep()
  475. Problem Report
  476. toLabel
  477. Address:
  478. toLabel
  479. Subject:
  480. toLabel
  481. Department:
  482. toLabel
  483. Problem Area:
  484. toLabel
  485. Phone::::::::
  486. toLabel
  487. Office: Area:
  488. toLabel
  489. Description of problem:
  490. Submit Report
  491. Office:
  492. Department:
  493. phone
  494. description
  495. problem
  496. Problem Report
  497. Phone:
  498. Description:
  499. Problem:
  500. sendMessage
  501. nstr_notSubmit
  502. s_MAPIError
  503. office
  504. department
  505. str_submit
  506. buttonClick
  507. buttonClick
  508. 4s_MAPIError
  509. ZmsgTxt
  510.     -- build the 
  511. message
  512. ' = "Problem Report"
  513. D = "Department:"
  514. combobox "department"
  515. 3problem"
  516.  = "Office:"
  517. "office"
  518.  = "Phone:"
  519. "phone"
  520.  = "Description:"
  521. "description" 
  522. sendMessage(
  523. "sub",
  524. str_notSubmit()&&
  525. str_submit()
  526. bmit Report
  527. enterPage
  528. &Submit Report
  529. &Receive Reports
  530. GvGvG
  531.  1993,1994. Asymetrix Corporation. All Rights Reserved.
  532. -- Author: Jim Geldmacher
  533. Mgives you permission 
  534. e, revise, 
  535. reuse the
  536. -- individual 
  537. scripts 
  538. your own
  539. -- applications.
  540. You may 
  541. H entire 
  542. -- substantial part 
  543. redistribution 
  544. ` product.
  545. retains 
  546.  copyright on 
  547.  original elements 
  548.  . Include 
  549.  notice
  550. --     "Portions 
  551.  1993, 1994. 
  552. they contain 
  553. copied 
  554. -- Standard ToolBook messages
  555. enterApplication
  556. xsysRuntime
  557.     -- link 
  558.  DLLs
  559. initLinks
  560. MAPI 
  561. available 
  562. isMAPIAvailable()
  563. SessionLogon()
  564. str_noMAPI()
  565. leaveApplication
  566. 4s_SessionHandle
  567. logged 
  568. ' <> 
  569. SessionLogoff()
  570. unlinkMAPI
  571.     -- unlinkDLLs
  572. related functions
  573. -- Notes:
  574. -- Functions that are exported 
  575. z have 
  576. four 
  577. their 
  578. other 
  579. y used 
  580. Udefined 
  581. %OpenScript "
  582. -- handlers.
  583. -- The basic 
  584. need 
  585. access 
  586. examples 
  587. -- here.
  588. -- There 
  589. two structures 
  590. store recipients
  591. Recipient Structure
  592. -- Offset    Type    Element
  593. --    0        DWORD    
  594.  Must be 0
  595. --    4        
  596. JClass
  597. --    8        POINTER    Pointer 
  598. Name 
  599. --    12        
  600. Address 
  601. --    16        
  602. \Size 
  603. Entry ID 
  604. bytes
  605. --    20        
  606. buffer.
  607. Classes
  608. --    0 = 
  609.  originator
  610. --    1 = primary 
  611. --    2 = ropy 
  612. --    3 = blind 
  613. Message 
  614. --    0        
  615. --    4        
  616. Subject 
  617. --    8        
  618. ?Text 
  619. --    12        
  620. . NULL 
  621. mail.
  622. --    16        
  623. Date. Format 
  624. YYYY/MM/DD HH:MM
  625. --    20        
  626. Thread ID. Ignored 
  627. Hsome systems.
  628. --    24        
  629. Mail Flags
  630. --    28        
  631. Sender's 
  632. --    32        
  633. Number 
  634. --    36        
  635. array 
  636. --    40        
  637. file attachments
  638. --    44        
  639.  descriptors
  640.  returns TRUE 
  641. FALSE otherwise.
  642. IsMAPIAvailable
  643. -- According 
  644. spec, 
  645.  should 
  646. a non-zero "
  647. ;" entry
  648. Y [MAIL] section 
  649. WIN.INI 
  650. determine 
  651. support 
  652. does 
  653. z, just a 
  654. ma_GetWinIniVar("
  655. -- sessionLogOn() attempts 
  656. --    If the 
  657. successful, 
  658. "OK" 
  659. returned. Otherwise, s_MAPIError 
  660. SessionLogOn
  661. ZlphSession, retVal
  662. getWinPointer(4)
  663. MAPILogon(
  664. ,"","",1,0,
  665.         -- extract 
  666.  = PointerDWORD(0,
  667.  = str_OK()
  668.         -- 
  669. what error occured
  670. = getMAPIErrorString(
  671.     -- free 
  672. freeWinPointer (
  673. -- sessionLogOff() 
  674. [off 
  675. current 
  676. -- If 
  677. "OK" 
  678. SessionLogOff
  679. MAPILogoff(
  680. ,0,0)
  681.         -- discard 
  682.         -- 
  683. = GetMAPIErrorString(
  684. -- getting 
  685.      IDs
  686. -- getFirstMsgID() 
  687. appropriate type
  688. newMail 
  689. only considers unread 
  690. -- folder 
  691. considered.
  692.  logical 
  693.     ,s_MAPIerror
  694. ZlpMsgSeedID,lpMsgID
  695.  mailFlag
  696. xisType(
  697. ,s_sessionHandle)
  698. str_lostMAPI()
  699.     -- assign buffers 
  700.  flag
  701.  = 32
  702. MAPIFindNext(
  703. , 0, 0, 
  704.         -- 
  705. there 
  706. value
  707.         msgID = 
  708.  = getMAPIerrorString(
  709.         -- 
  710. -- getNextMsgID() 
  711. _ lastID,
  712.  = 32
  713. , 0, 0, 
  714.         -- 
  715.         -- 
  716. -- reading 
  717. -- getMsgName() reads 
  718. specified 
  719. sender. If 
  720. ZlpPtrMsg,
  721. ZlpSender,lpName
  722. ZmsgName
  723.     -- allocate a 
  724. recieve a 
  725. ("envelope") 
  726.     -- 0x00C0 = MAPI_ENVELOPE_ONLY + MAPI_PEEK
  727. MAPIReadMail(
  728.         -- 
  729.         -- 
  730. 0(28,
  731.         -- 
  732.         -- 
  733. MAPIFreeBuffer(
  734. allocated memory
  735. -- getMsgSub() 
  736. subject 
  737. . If 
  738. ZlpSubject
  739. ZmsgSub
  740.     -- 0
  741.         -- 
  742.         -- 
  743.         -- 
  744.         -- 
  745. -- getMsgDate() 
  746. was received. If 
  747. ZlpDate
  748. ZtmpDate,tmpTime
  749. ZmsgDate
  750.     -- 0
  751.         -- 
  752.         -- 
  753. 0(16,
  754.         -- 
  755.         -- 
  756.         -- reformat 
  757. default 
  758. "y/mm/dd"
  759. "h24:
  760. -- getMsgText() 
  761. . If 
  762. ZlpText
  763. ZmsgTxt
  764.  (ignore 
  765.     -- 0x0180 = 
  766.  + MAPI_SUPPRESS_ATTACH
  767.         msgText = 
  768.         -- 
  769.         -- 
  770.         -- 
  771.         -- 
  772. addresses
  773. -- getAddress() calls up 
  774. dialog box. If no 
  775. -- occurs 
  776. list 
  777. W chosen 
  778. ZlpPtrNum
  779. ZlpPtrRec,lpRec
  780.  recNum
  781.  recOffset
  782. ZrecNames
  783.     -- display 
  784. MAPIAddress(
  785. ,0,"",1,"",0,0,1,0,
  786.         -- retrieve 
  787.             -- 
  788.             -- 
  789. through 
  790.  = (i-1)* 24
  791.             -- frre 
  792. names
  793. -- checkNames() takes a 
  794. partial 
  795. 1. If 
  796. > could be
  797. -- resolved 
  798. full mailing 
  799.  consists 
  800. containing 
  801. those 
  802. ZSTACK goodNames,badNames
  803. Xeach 
  804.         -- 
  805.         -- 0x0409 = MAPI_LOGON_UI + MAPI_DIALOG + MAPI_AB_NOMODIFY
  806. MAPIResolveName(
  807.             -- 
  808. pcannot be 
  809.             -- 
  810.             -- 
  811.             lpRecip = 
  812.             -- 
  813.             -- 
  814. valid 
  815.             -- 
  816. -- sending 
  817. -- composeMessage() displays 
  818. coposing
  819. . If 
  820. "OK" 
  821. 4s_Sessionhandle,
  822. blank 
  823.     -- 0x0009 = 
  824. MAPISendMail(0,0,
  825. -- sendFile() opens 
  826.  mesage 
  827. -- attached 
  828. !. Null 
  829. -- "OK" 
  830. l fileName
  831. MAPISendDocuments(0, ";", 
  832. p, shortFileName(
  833. ), 0)
  834. -- sendMessage() sends a 
  835. "OK" 
  836. a recipent 
  837. -- ambiguous 
  838. user will be prompted 
  839. clarify
  840.  recips,
  841. ZlpBuff,lpTmp
  842. Zstack recipStack
  843.   numRec
  844. ZLONG count
  845.     -- find out many 
  846. z"so enough 
  847.     -- can be 
  848.         -- a 
  849.   which 
  850.         -- a 
  851.         -- a 
  852.         -- a 
  853.         -- a 
  854.     -- create a 
  855.     -- fill 
  856.         -- 
  857.         -- 
  858.         -- 0
  859. UI + 
  860.             -- 
  861.             -- 
  862.             -- 
  863. contents 
  864.             -- optimization: 
  865. Windows 
  866. much faster
  867.             -- than stepping 
  868. ma_hmemcpy(
  869.             -- 
  870. / counter 
  871.             -- keep track 
  872. cleanup later
  873.  were 
  874.         -- 
  875. strings
  876.         -- 
  877. ,(32,
  878. 0(36,
  879.         -- 
  880. ,1,0)
  881. -! = 
  882.         -- 
  883.         -- pointers 
  884. 2'stored 
  885. %a 2-
  886. order 
  887.         -- 
  888. necessary 
  889. grab 
  890. -- deleting 
  891. -- deleteMessage() removes 
  892. {$ "OK 
  893. MAPIDEleteMail(
  894. ,0,0)
  895. ]# = 
  896. l# = 
  897. -- Utility 
  898. "code associated 
  899. " nErrorNumber
  900.         When 
  901. "Operation Succeded"            --SUCCESS_SUCCESS 
  902. "User Aborted"
  903. --MAPI_USER_ABORT 
  904. kFailed"            --MAPI_E_FAILURE
  905. "Login 
  906. 0    --MAPI_E_LOGIN_FAILURE 
  907. "Disk Full"
  908. --MAPI_E_DISK_FULL 
  909. "Insufficient Memory"        --MAPI_E_INSUFFICIENT_MEMORY 
  910. "Block Too Small"            --MAPI_E_BLK_TOO_SMALL 
  911. 5Many Sessions"            --MAPI_E_TOO_MANY_SESSIONS 
  912. ?Files"
  913. --MAPI_E_TOO_MANY_FILES 
  914. yRecipients"        --MAPI_E_TOO_MANY_RECIPIENTS 
  915. "Attacment Not Found"        --MAPI_E_ATTACHMENT_NOT_FOUND 
  916. "Failure Opening Attachment"    --
  917. LOPEN_FAILURE 
  918. ?Writing 
  919. |WRITE_FAILURE 
  920. "Unknown 
  921. +"            --MAPI_E_UNKNOWN_RECIPIENT 
  922. "Bad 
  923. +"            --MAPI_E_BAD_RECIPTYPE 
  924. "No Messages"
  925. --MAPI_E_NO_MESSAGES 
  926. "Invalid 
  927. ;"            --MAPI_E_INVALID_MESSAGE 
  928. Large"            --MAPI_E_TEXT_TOO_LARGE 
  929. /"            --MAPI_E_INVALID_SESSION 
  930. Supported"            --MAPI_E_TYPE_NOT_SUPPORTED 
  931. "Ambiguous 
  932. L-"        --MAPI_E_AMBIGUOUS_RECIPIENT 
  933. (:"&& 
  934. *a filename 
  935. .has been stripped 
  936. path information
  937.  fName
  938. harCnt, i
  939.     charCnt = 
  940. - 1) 
  941. Vi+1 
  942. )) allocates a block 
  943. global 
  944. ) nSize
  945. ZhMem,ptr
  946.  ma_globalAlloc(66,
  947. %) -- 66 
  948. Movable, Zero-Init
  949. str_noMem()
  950. ma_globalLock(
  951. n)() frees 
  952. )lpPointer
  953.  = ma_globalHandle(
  954. ') -- 
  955. Hselector)
  956. ma_globalUnlock(
  957. ma_globalFree(
  958. h1() establishes a 
  959. @2DLL 
  960. --    a 
  961. & indicating 
  962. found.
  963.     sysS = 
  964. provide messaging 
  965. X"mapi.dll"
  966. X0, STRING, 
  967. g1, \
  968. 1 MAPIDeleteMail (
  969. .links 
  970. kernel 
  971. # managment 
  972.         INT     
  973. tbkwin 
  974. 4 "tb30win.
  975.     ma_getWinIniVar=
  976. 4 disconnects 
  977. str_noUnread
  978. str_msgCountAll 
  979. str_msgCountUnread 
  980. R5"&&
  981. {6            
  982. I."&&\
  983. 5Microsoft 
  984. 6-compatible e-
  985. 3 client software installed"&&\
  986. 26 correctly."        
  987. I."&&\
  988. F,"&&\
  989. %9wish 
  990. str_notResolved
  991. "These 
  992. str_sent
  993. str_notSent
  994. str_notSubmit
  995. "Report 
  996. xsubmitted:"
  997. str_submit
  998. str_notDelete
  999. xdeleted:"
  1000. str_noMessages
  1001. str_error
  1002. str_update
  1003. "Update 
  1004. str_cancel
  1005. "Cancel"
  1006. str_message
  1007. str_of
  1008. str_problemRep
  1009. "Problem 
  1010. "Aborting operation: 
  1011.  Allocation 
  1012. buttonClick
  1013. ZnameText,subText,scrollText
  1014. ZLONG msgNum
  1015. the ID 
  1016. unread message
  1017. getFirstMsgID(TRUE)
  1018.     -- repeat 
  1019. Zno more messages are found
  1020.     -- optimization: 
  1021. faster 
  1022. aincremental 
  1023. Fplace 
  1024. , than 
  1025. Qdirectly 
  1026. . In 
  1027. list 
  1028. generated one 
  1029. Fplaced 
  1030. fields 
  1031. complete.
  1032.         -- extract 
  1033. sender 
  1034.  = getMsgName(
  1035.         -- 
  1036. subject 
  1037.  = getMsgSub(
  1038.         -- 
  1039. places dummy 
  1040. (only 
  1041.         -- 
  1042. shows on th 
  1043.         -- 
  1044. technique allows you 
  1045.         -- much 
  1046. smoothly
  1047.         -- 
  1048. getNextMsgID(
  1049. str_noUnread()
  1050.         -- 
  1051. "Subject" = 
  1052. "ScrollBar" = 
  1053.     -- update the status 
  1054. updateMessages
  1055. 4LONG s_MsgCount,s_MsgNum
  1056.     -- initialize 
  1057. flist 
  1058. messages
  1059. initMessageList str_problemRep()
  1060. there 
  1061. )least one 
  1062. z > 0
  1063.         -- 
  1064. invalid reset 
  1065.  = 0 
  1066.         -- parse 
  1067. current 
  1068. parseMsgText
  1069.         -- 
  1070. browsing buttons
  1071.             enabled 
  1072. " = FALSE
  1073. " = TRUE
  1074. t" = 
  1075. t" = 
  1076. B"delete" = 
  1077.         -- 
  1078. are no 
  1079.  fields
  1080. "msgnum" = str_noMessages()
  1081. "address"
  1082. "department"
  1083. "office"
  1084. "phone"
  1085. "description"
  1086. "timestamp"
  1087.         -- 
  1088. t" = 
  1089. -- generate a 
  1090.  than contain 
  1091. filter 
  1092. their subjects
  1093. 4s_MsgHandles
  1094. 4s_MAPIerror
  1095. ZlastID
  1096. ZmsgSub
  1097. getFirstMsgID(
  1098. more 
  1099.         -- 
  1100.  = getMsgSub(
  1101.         -- 
  1102.         -- 
  1103. getNextMsgID(
  1104. -- take 
  1105. fill 
  1106. appropriate 
  1107. 4s_MAPIError
  1108. ZmsgTxt
  1109. ender 
  1110. getCurrentMsgName()
  1111. k&str_update() 
  1112. fstr_OK() 
  1113. str_cancel()
  1114.  = getCurrentMsgText()
  1115. &&str_of()&&
  1116.  = getCurrentMsgDate()
  1117.  returns 
  1118. getMsgName(
  1119. getMsgText(
  1120. getMsgDate(
  1121. initLinks
  1122. 3SessionLogon
  1123. isMAPIAvailable
  1124. str_noMAPI
  1125. enterApplication
  1126. unlinkDLLs
  1127. s_SessionHandle
  1128. USessionLogoff
  1129. unlinkMAPI
  1130. leaveApplication
  1131. reader
  1132. FALSE
  1133. ma_GetWinIniVar
  1134. clinkMAPI
  1135. IsMAPIAvailable
  1136. freeWinPointer
  1137. $bgetWinPointer
  1138. MAPILogon
  1139. s_SessionHandle
  1140. str_OK
  1141. DgetMAPIErrorString
  1142. s_MAPIError
  1143. SessionLogOn
  1144. s_SessionHandle
  1145. str_OK
  1146. MAPILogoff
  1147. DGetMAPIErrorString
  1148. s_MAPIError
  1149. SessionLogOff
  1150. .&+    +E
  1151. $bgetWinPointer
  1152. msgID
  1153. s_SessionHandle
  1154. MAPIFindNext
  1155. d3str_lostMAPI
  1156. DgetMAPIerrorString
  1157. s_MAPIerror
  1158. getFirstMsgID
  1159. .&+    +E
  1160. $bgetWinPointer
  1161. s_SessionHandle
  1162. lpMsgSeedID
  1163. MAPIFindNext
  1164. d3str_lostMAPI
  1165. DgetMAPIerrorString
  1166. s_MAPIerror
  1167. lpMsgID
  1168. getNextMsgID
  1169. .&+    +E
  1170. freeWinPointer
  1171. $bgetWinPointer
  1172. s_SessionHandle
  1173. 8aMAPIFreeBuffer
  1174. d3str_lostMAPI
  1175. DgetMAPIErrorString
  1176. s_MAPIerror
  1177. MAPIReadMail
  1178. getMsgName
  1179. .&+    +E
  1180. freeWinPointer
  1181. $bgetWinPointer
  1182. s_SessionHandle
  1183. 8aMAPIFreeBuffer
  1184. d3str_lostMAPI
  1185. DgetMAPIErrorString
  1186. s_MAPIerror
  1187. MAPIReadMail
  1188. getMsgSub
  1189. .&+    +E
  1190. freeWinPointer
  1191. $bgetWinPointer
  1192. s_SessionHandle
  1193. 8aMAPIFreeBuffer
  1194. y/mm/dd
  1195. d3str_lostMAPI
  1196. DgetMAPIErrorString
  1197. s_MAPIerror
  1198. h24:min
  1199. MAPIReadMail
  1200. getMsgDate
  1201. .&+    +E
  1202. freeWinPointer
  1203. $bgetWinPointer
  1204. s_SessionHandle
  1205. 8aMAPIFreeBuffer
  1206. d3str_lostMAPI
  1207. DgetMAPIErrorString
  1208. s_MAPIerror
  1209. msgText
  1210. MAPIReadMail
  1211. getMsgText
  1212. .&+    +E
  1213. ,%H.%
  1214. freeWinPointer
  1215. $bgetWinPointer
  1216. s_SessionHandle
  1217. 8aMAPIFreeBuffer
  1218. MAPIAddress
  1219. d3str_lostMAPI
  1220. DgetMAPIErrorString
  1221. s_MAPIError
  1222. getAddress
  1223. .&+    +E
  1224. ,%H.%
  1225. freeWinPointer
  1226. $bgetWinPointer
  1227. s_SessionHandle
  1228. 8aMAPIFreeBuffer
  1229. MAPIResolveName
  1230. d3str_lostMAPI
  1231. DgetMAPIerrorString
  1232. s_MAPIError
  1233. checkNames
  1234. .&+    +E
  1235. freeWinPointer
  1236. $bgetWinPointer
  1237. s_Sessionhandle
  1238. str_OK
  1239. d3str_lostMAPI
  1240. DgetMAPIErrorString
  1241. s_MAPIError
  1242. MAPISendMail
  1243. composeMessage
  1244. .&+    +E
  1245. s_Sessionhandle
  1246. MAPISendDocuments
  1247. str_OK
  1248. HshortFileName
  1249. d3str_lostMAPI
  1250. DgetMAPIErrorString
  1251. s_MAPIError
  1252. sendFile
  1253. .&+    +E
  1254. freeWinPointer
  1255. $bgetWinPointer
  1256. ma_hmemcpy
  1257. s_Sessionhandle
  1258. str_OK
  1259. 8aMAPIFreeBuffer
  1260. MAPISendMail
  1261. MAPIResolveName
  1262. d3str_lostMAPI
  1263. DgetMAPIerrorString
  1264. s_MAPIError
  1265. recipient
  1266. sendMessage
  1267. .&+    +E
  1268. [MAPIDEleteMail
  1269. s_SessionHandle
  1270. str_OK
  1271. d3str_lostMAPI
  1272. DgetMAPIerrorString
  1273. s_MAPIError
  1274. deleteMessage
  1275. .&,    "
  1276. .&,    "
  1277. .&,    "
  1278. .&,    "
  1279. .&,    "
  1280. .&,    "
  1281. .&,    "
  1282. .&,    "
  1283. .&,    "
  1284. .&,    "
  1285. .&,    "
  1286. .&,    "
  1287. .&,    "
  1288. .&,    "
  1289. .&,    "
  1290. .&,    "
  1291. .&,    "
  1292. .&,    "
  1293. .&,    "
  1294. .&,    "
  1295. .&,    "
  1296. Too Many Sessions
  1297. Too Many Files
  1298. Invalid Message
  1299. Block Too Small
  1300. Too Many Recipients
  1301. Failure Opening Attachment
  1302. Invalid Session
  1303. Attacment Not Found
  1304. Failure Writing Attachment
  1305. Bad Recipient Type
  1306. Type Not Supported
  1307. Insufficient Memory
  1308. No Messages
  1309. Disk Full
  1310. Login Failed
  1311. Operation Succeded
  1312. Text is Too Large
  1313. Unknown Recipient
  1314. User Aborted
  1315. Operation Failed
  1316. Unknown error:
  1317. Ambiguous Recipient
  1318. getMAPIErrorString
  1319. shortFileName
  1320. &ma_globalLock
  1321. str_noMem
  1322. Kma_globalAlloc
  1323. getWinPointer
  1324. !pma_globalHandle
  1325. ma_globalUnlock
  1326. } ma_globalFree
  1327. freeWinPointer
  1328. mapi.dll
  1329. MAPILogoff
  1330. ,&UG?
  1331. MAPILogon
  1332. MAPIFindNext
  1333. MAPIFreeBuffer
  1334. MAPISendMail
  1335. MAPIReadMail
  1336. ,BUny F.&
  1337. MAPIResolveName
  1338. MAPISendDocuments
  1339. MAPIAddress
  1340. MAPIDeleteMail
  1341. linkMAPI
  1342. tb30win.dll
  1343. globalAlloc
  1344. ma_globalAlloc
  1345. globalLock
  1346. ma_globalLock
  1347. ,#U?    
  1348. globalUnlock
  1349. ma_globalUnlock
  1350. ,#TW*If-"
  1351. globalFree
  1352. ma_globalFree
  1353. globalHandle
  1354. ma_globalHandle
  1355. ,"TG?    
  1356. hmemcpy
  1357. ma_hmemcpy
  1358. getWinIniVar
  1359. ma_getWinIniVar
  1360. kernel
  1361. initLinks
  1362. mapi.dll
  1363. unlinkMAPI
  1364. tb30win.dll
  1365. kernel
  1366. unlinkDLLs
  1367. You have no unread messages.
  1368. str_noUnread
  1369. You have
  1370. messages.
  1371. str_msgCountAll
  1372. unread messages.
  1373. You have
  1374. str_msgCountUnread
  1375. MAPI is not available at this time.
  1376. You need to have Microsoft Mail or MAPI-compatible e-mail client software installed
  1377. for the examples in this book to function correctly.
  1378. str_noMAPI
  1379. The examples in this book will not function correctly,
  1380. MAPI is not available at this time.
  1381. you may wish to exit.
  1382. str_lostMAPI
  1383. str_OK
  1384. These names could not be resolved:
  1385. str_notResolved
  1386. Message sent.
  1387. str_sent
  1388. Message not sent:
  1389. str_notSent
  1390. Report not submitted:
  1391. str_notSubmit
  1392. Report submitted.
  1393. str_submit
  1394. Message not deleted:
  1395. str_notDelete
  1396. No messages
  1397. str_noMessages
  1398. Error:
  1399. str_error
  1400. Update Messages?
  1401. str_update
  1402. Cancel
  1403. str_cancel
  1404. Message
  1405. str_message
  1406. str_of
  1407. Problem Report
  1408. str_problemRep
  1409. Aborting operation: Memory Allocation Error.
  1410. str_noMem
  1411. .&+    +E
  1412. .%,    7
  1413. .&+    +E
  1414. (str_noUnread
  1415. l'getNextMsgID
  1416. ScrollBar
  1417. getMsgSub
  1418. 1RgetFirstMsgID
  1419. Subject
  1420. getMsgName
  1421. buttonClick
  1422. uupdateMessages
  1423. enterPage
  1424. +%,!"
  1425. +%,!>
  1426. +%,!"
  1427. .&+%?
  1428. problem
  1429. s_MsgNum
  1430. phone
  1431. address
  1432. description
  1433. str_noMessages
  1434. previous
  1435. delete
  1436. 8parseMsgText
  1437. initMessageList
  1438. msgnum
  1439. office
  1440. department
  1441. timestamp
  1442. str_problemRep
  1443. s_MsgCount
  1444. updateMessages
  1445. .&+    +E
  1446. .&+%?
  1447. +%,!Y
  1448. +%,H3
  1449. .&+    +E
  1450. FALSE
  1451. l'getNextMsgID
  1452. getMsgSub
  1453. s_MsgHandles
  1454. 1RgetFirstMsgID
  1455. s_MsgCount
  1456. initMessageList
  1457. w,    #>
  1458. +%,    #?
  1459. w,    #?
  1460. +%,    #?
  1461. address
  1462. s_MAPIError
  1463. phone
  1464. str_cancel
  1465. description
  1466. 'getCurrentMsgText
  1467. str_message
  1468. getCurrentMsgDate
  1469. problem
  1470. uupdateMessages
  1471. str_OK
  1472. getCurrentMsgName
  1473. msgnum
  1474. str_update
  1475. str_of
  1476. s_MsgNum
  1477. Error:
  1478. office
  1479. department
  1480. timestamp
  1481. s_MsgCount
  1482. parseMsgText
  1483. +%,H3
  1484. s_MsgNum
  1485. s_MsgHandles
  1486. getMsgName
  1487. getCurrentMsgName
  1488. +%,H3
  1489. getMsgText
  1490. s_MsgNum
  1491. s_MsgHandles
  1492. getCurrentMsgText
  1493. +%,H3
  1494. s_MsgNum
  1495. s_MsgHandles
  1496. getMsgDate
  1497. getCurrentMsgDate
  1498. examples
  1499. in,true
  1500. ThreeDeeRect
  1501. text area
  1502. bottomLine
  1503. topLine
  1504. description
  1505. description
  1506. enterpage
  1507. doesn't fit, 
  1508. notifybefore 
  1509. "description" 
  1510. Front
  1511. front
  1512. enterpage
  1513. handler keeps the title 
  1514. synchronized
  1515. notifybefore 
  1516. "front" 
  1517. buttonClick
  1518. enterPage
  1519. buttonClick
  1520. -- determine 
  1521. navigation 
  1522. should be allowed
  1523. notifybefore 
  1524. on a different 
  1525. oenabled = (
  1526. Previous
  1527. buttonClick
  1528. enterPage
  1529. .one 
  1530. buttonClick
  1531. -- determine 
  1532. navigation 
  1533. should be allowed
  1534. notifybefore 
  1535. on a different 
  1536. oenabled = (
  1537. main menu
  1538. buttonClick
  1539. main menu
  1540. enterPage
  1541. the main 
  1542. buttonClick
  1543. -- determine 
  1544. Bnavigation 
  1545. Ienu 
  1546. should be allowed:
  1547. notifybefore 
  1548. ycurrent 
  1549. oenabled = (
  1550. in,true
  1551. ThreeDeeRect
  1552. work area
  1553. bottomLine
  1554. topLine
  1555. enterPage
  1556. main menu
  1557. -- a notify handler was used 
  1558. update 
  1559. you enter 
  1560. Main Menu
  1561. Main Menu
  1562. buttonClick
  1563. ,%H.%
  1564. front
  1565. enterpage
  1566. buttonClick
  1567. ZLONG lineNum
  1568.     -- determine which 
  1569. Uwas selected 
  1570. * = selectedTextlines 
  1571. that 
  1572. -- update the 
  1573. list 
  1574. notifybefore 
  1575. ZSTRING newText
  1576.     -- generate a 
  1577.     -- optimization: 
  1578. faster 
  1579. aincremental 
  1580. place 
  1581. , than 
  1582.     -- directly 
  1583. B(i-1) 
  1584. J"front" 
  1585. Using MAPI
  1586. Linking to MAPI.DLL
  1587. Looking up Addresses
  1588. Verifying Names
  1589. Checking For Unread Mail
  1590. Counting Messages
  1591. Composing Mail
  1592. Sending Messages
  1593. Example: Problem Reports
  1594. Choose one of these topics:low by clicking on its name:
  1595. enterpage
  1596. Example: Problem Reports
  1597. Example: Problem Reports
  1598. Example: Problem Reports+
  1599. The following two examples demonstrate how a small MAPI application, such as a custom e-mail form, might be built in ToolBook. 
  1600. The first example is a guided input form for submitting problem reports. The user simply fills in the blanks and clicks on a button to submit the report.
  1601. The second example scans the user's incoming mail folder for problem reports submitted using the e-mail form. This provides a simple interface for browsing through these messages...................................
  1602. Submit Reports
  1603. examples
  1604. Submit Reports
  1605. buttonClick
  1606. buttonClick
  1607.     -- display a 
  1608. example
  1609. "examples"
  1610.     currentpage 
  1611. "Submit Reports"
  1612. &Submit Reports
  1613. Receive Reports
  1614. Receive Reports
  1615. examples
  1616. buttonClick
  1617. buttonClick
  1618.     -- display a 
  1619. example
  1620. "examples"
  1621.     currentpage 
  1622. "Receive Reports"
  1623. &Receive Reports
  1624. main menu
  1625. right
  1626. grey all
  1627. grey left
  1628. grey right
  1629. Looking up Addresses
  1630. -- a notify handler was used 
  1631. the address 
  1632. you enter 
  1633. Looking up Addressesok]
  1634. Looking up Addressesokkess Book
  1635. Click Look Up Address to display the dialog box MAPI provides for choosing addresses. Names you select from the list will be placed in the field below...........................
  1636. Look Up Address
  1637. nameList
  1638. getAddress
  1639. s_MAPIError
  1640. buttonClick
  1641. buttonClick
  1642. 4s_MAPIError
  1643. up the Address Book dialog 
  1644. retrieve a list 
  1645. names
  1646.     nameList = getAddress()
  1647. returned - 
  1648. error condition
  1649. &Look Up Address
  1650. enterPage
  1651. notifybefore 
  1652. enterPage
  1653.