home *** CD-ROM | disk | FTP | other *** search
/ .net 1999 December / netCD65.iso / pc / Software / VirtualA / 32bit / vasetup.exe / %MYDIR% / MAILEXT.EBS < prev    next >
Encoding:
Text File  |  1999-10-06  |  8.3 KB  |  235 lines

  1. 'T:MAILEXT.EBS for CIX
  2. ' VA 4.52 release
  3.  
  4. 'Add file to import queue
  5. Declare Function AddToDoList16 Pascal Lib "addons.dll" Alias "AddToDoList" (ByVal szService As String, ByVal szFileName As String, ByVal szMailname As String, ByVal iFlags As Long) As Integer
  6. Declare Function AddToDoList32 Pascal Lib "addons32.dll" Alias "AddToDoList" (ByVal szService As String, ByVal szFileName As String, ByVal szMailname As String, ByVal iFlags As Long) As Long
  7. Declare Sub AddToMsgFile(SourceFileName as String)
  8. Declare Function QueueFile(service As String, sfilename As String, queueflags As Long) As Boolean
  9. Declare Function QueueFileList(service As String, sfilename As String, topic As String) As Boolean
  10. Declare Sub LoadAddonLibraries
  11. Declare Function AddFileToMessageBase(topic As String, subject As String, filename As String)
  12. Declare Function MyDate$
  13. Declare Function FileUrl(fn As String) As String
  14.  
  15. 'T:iFlags for CIX (constant)
  16. Const IM_DELETE = 2048       ' Delete scratchpad file afterwards?
  17.  
  18. Public Success As Boolean      'Whether command succeeded
  19. Public Failure As String       'Reason command failed (CIX error message)
  20.  
  21. 'T:Binmail (subroutine) (CIX)
  22. Sub BinMail(id As String, person As String, filename As String)
  23.     Dim t As Tracker
  24.     Dim cixfilename As String
  25.  
  26.     cixfilename = FileName$(filename)
  27.     EnterMail "binmail " + person + " " + cixfilename + "\r"
  28.     TrackFailure "File*not found"
  29.     Set t = CreateTracker("sctrack2", "User*unknown", "FailureMatched", False, True)
  30.     WaitForMainPrompt
  31.     t.delete
  32.     ReportSuccessFlag id & " : Send Binmail of " & filename & " to " & person
  33.     EatExtraPrompts
  34. End Sub
  35.  
  36. 'T:EraseMailFile (subroutine) (CIX)
  37. Sub EraseMailFile(id As String, filename As String)
  38.     filename = FileName$(filename)
  39.     EnterMail "era " + filename + "\r"
  40.     TrackFailure "File*not found"
  41.     Trackers("YES").active = True
  42.     WaitForMainPrompt
  43.     Trackers("YES").active = False
  44.     ReportSuccessFlag id & " : Erased " & filename & " from mail"
  45.     EatExtraPrompts
  46. End Sub
  47.  
  48. 'T:RenameMailFile (subroutine) (CIX)
  49. Sub RenameMailFile(id As String, filename As String, newname As String)
  50.     EnterMail "ren " + filename + " " + newname + "\r"
  51.     TrackFailure "File*not found"
  52.     WaitForMainPrompt
  53.     ReportSuccessFlag id & " : Renamed " & filename & " to " & newname & " in mail"
  54.     EatExtraPrompts
  55. End Sub
  56.  
  57. 'T:ExportMailFile (subroutine) (CIX)
  58. Sub ExportMailFile(id As String, topic As String, filename As String)
  59.     If Not JoinConference(id, topic) Then Exit Sub
  60.     Terminal.Status "Exporting " & filename & "from mail to " & topic
  61.     EnterMail "export " + filename + "\r"
  62.     TrackFailure "You don't have such a file in your subdir."
  63.     WaitForMainPrompt
  64.     If Not Success Then Failure = "File '" + filename + "' not in your mail directory"
  65.     ReportSuccessFlag id & " : Exported " & filename & " from mail to " & topic
  66.     EatExtraPrompts
  67.     Terminal.Status ""
  68. End Sub
  69.  
  70. 'T:SendFileViaMail (subroutine) (CIX)
  71. Sub SendFileViaMail(id As String, filename As String, user As String, _
  72.                     subject As String)
  73.     GotoArea "Main"
  74.     Comms.Send "killscratch\r"
  75.     WaitForMainPrompt
  76.     Comms.Send "upload\r"
  77.     WaitFor "X)"
  78.     FileUpload PROT_ZMODEM, filename,, True
  79.     WaitForMainPrompt
  80.     Comms.Send "mail to " + user + "\r"
  81.     WaitFor "subject:"
  82.     Comms.SendLiteral subject
  83.     Comms.Send "\r"
  84.     WaitForPrompt "PromptEdit"
  85.     Comms.Send "q\r"
  86.     WaitForPrompt "PromptSend"
  87.     TrackFailure "-->*<--\n*\n"
  88.     Comms.Send "send\r"
  89.     WaitForMainPrompt
  90.     ReportSuccessFlag id & " : Sent " & filename & " to " & user & " as a mail message"
  91.     EatExtraPrompts
  92. End Sub
  93.  
  94. 'T:MarkMailUnread (subroutine) (CIX)
  95. Sub MarkMailUnread(id As String, message As String)
  96.     Dim IniCounter as Integer
  97.     Dim MailLine as String
  98.     Dim ListIni as String
  99.  
  100.     If message="All Mail in Inbasket" then
  101.         ReadMailBasket id, "Inbasket" 'updates list.ini with all the unread mail
  102.         ListIni$ = Session.ServicePath+"list.ini"
  103.         IniCounter = 2
  104.         MailLine = ReadIni$("Mail Messages", CStr(IniCounter), ListIni)
  105.         Comms.Send "mail\r"
  106.         WaitForPrompt "Prompt"
  107.         Do While Instr(MailLine,":") <> 0
  108.             MailLine = Trim$(Left$(MailLine, Instr(MailLine, ":")-1))
  109.             Comms.Send "markunread " + MailLine + "\r"
  110.             WaitForPrompt "Prompt"
  111.             IniCounter = IniCounter +1
  112.             MailLine = ReadIni$("Mail Messages", CStr(IniCounter), ListIni)
  113.         Loop
  114.         ReportSuccess id & " : Marked All message in mail inbox as unread"
  115.         EatExtraPrompts
  116.     Else
  117.         If Instr(message, ":") then
  118.             message = Trim$(Left$(message, Instr(message, ":")-1))
  119.         End If
  120.         EnterMail "markunread " + message + "\r"
  121.         WaitForMainPrompt
  122.         ReportSuccess id & " : Marked #" & message & " as unread in mail"
  123.         EatExtraPrompts
  124.     End If
  125. End Sub
  126.  
  127. 'T:ReadMailBasket (subroutine) (CIX)
  128. Sub ReadMailBasket(id As String, basket As String)
  129.     Dim fname As String
  130.     Dim ListIni$
  131.     Dim InFileNum%
  132.     Dim ALine$
  133.     Dim IniNumCounter%
  134.     Dim LineToWrite$
  135.  
  136.     On Error Goto ReadMailBasket_error
  137.     GotoArea "Main"
  138.     Comms.Send "file time\r"
  139.     WaitForMainPrompt
  140.     If Mid$(basket, 1, 1)="S" Then
  141.         EnterMail "file status\r"
  142.     ElseIf Mid$(basket, 1, 1)="I" Then
  143.         EnterMail "file in\r"
  144.     ElseIf Mid$(basket, 1, 1)="O" Then
  145.         EnterMail "file out\r"
  146.     End If
  147.     WaitForMainPrompt
  148.     Comms.Send "file echo ----------\r"
  149.     WaitForMainPrompt
  150.     
  151.     fname = UniqueFileName$()
  152.     If Not DownloadScratchpad(id, fname) Then Exit Sub
  153.  
  154.     If Mid$(basket, 1, 1) <> "O" then
  155.         'Write the inifile stuff
  156.         ListIni$ = Session.ServicePath+"list.ini"
  157.         WriteIni "Mail Messages", "", "", ListIni
  158.         WriteIni "Mail Messages", "1", "All Mail in Inbasket", ListIni$
  159.         InFileNum% = FreeFile
  160.         Open fname for Input Access Read Shared as #InFileNum%
  161.         ALine$ = ""
  162.         While Eof(InFileNum%)=False And (Left$(ALine$,4) <> "From")
  163.             'Read and look for the "From"
  164.             Line Input #InFileNum%, ALine$
  165.         Wend
  166.         If Left$(ALine$, 4) <> "From" Then 
  167.             Close #InFileNum%
  168.             Exit Sub
  169.         End If
  170.         Line Input #InFileNum%, ALine$
  171.         IniNumCounter% = 1
  172.         While Eof(InFileNum%)=False And (Left$(ALine$,4) <> "----")
  173.             If Len(ALine$) > 17 Then
  174.                 IniNumCounter% = IniNumCounter% +1
  175.                 LineToWrite = Mid$(ALine$,17,6) & " : " & Left$(ALine$, 16) & " : " & Right$(Aline$, 30)
  176.                 WriteIni "Mail Messages", Trim$(Str$(IniNumCounter%)), LineToWrite$, ListIni$
  177.             End If
  178.             Line Input #InFileNum%, ALine$
  179.         Wend
  180.         Close #InFileNum%
  181.     End If
  182.  
  183.     If AddFileToMessageBase("mail/baskets", "Mail " + basket + " " + MyDate$, fname) Then
  184.         ReportSuccess id & " : Collected information about mail " & basket
  185.     Else
  186.         ReportFailure id, Error$ & " " & Err & " " & Erl '" : Mail baskets information not collected/processed"
  187.     End If
  188.  
  189.     EatExtraPrompts
  190.     Exit Sub
  191.  
  192. ReadMailBasket_error:
  193.     Close #InFileNum%
  194.     ReportFailure id, Error$ & " : Mail baskets not collected/processed"
  195.     EatExtraPrompts
  196. End Sub
  197.  
  198. 'T:DeleteMail (subroutine) (CIX)
  199. Sub DeleteMail(id As String, message As String)
  200.     EnterMail "delete " + message + "\r"
  201.     Trackers("YES").active = True
  202.     WaitForMainPrompt
  203.     Trackers("YES").active = False
  204.     ReportSuccess id & " : Erased message #" & message & " in mail"
  205.     EatExtraPrompts
  206. End Sub
  207.  
  208. 'T:RefreshMailDir (subroutine) (CIX)
  209. Sub RefreshMailDir(id As String)
  210.     Dim fname As String
  211.  
  212.     GotoArea "Main"
  213.     EnterMail "file dir\r"
  214.     WaitForMainPrompt
  215.  
  216.     fname = UniqueFileName$()
  217.     If Not DownloadScratchpad(id, fname) Then Exit Sub
  218.     If QueueFileList(Session.Service, fname, "mail/directory")=True Then
  219.         ReportSuccess id & " : Refresh mail directory"
  220.         SetLastUpdated "Refresh Mail Directory"
  221.     Else
  222.         ReportFailure id, "Empty scratchpad or download failure"
  223.     End If
  224. End Sub
  225.  
  226. 'T:ClearMail (subroutine) (CIX)
  227. Sub ClearMail(id As String)
  228.     EnterMail "clear in quick clear out quick\r"
  229.     WaitForMainPrompt
  230.     ReportSuccess id & " : Cleared read mail on CIX"
  231.     SetLastUpdated "Clear Read Mail"
  232.     EatExtraPrompts
  233. End Sub
  234.  
  235.