This version wraps ALL the tsNet calls in a try catch construct:

function IMAPGetHeaders pServer, pUser, pPass
   if pServer is empty then
      ask "Enter IMAP Server IP or address:" as sheet
      if the result is "Cancel" then return "Canceled."
      put it into pServer
   end if
   
   if pUser is empty then
      ask "Enter email address:" as sheet
      if the result is "Cancel" then return "Canceled."
      put it into pUser
   end if
   
   if pPass is empty then
      ask password "Enter password:" as sheet
      if the result is "Cancel" then return "Canceled."
      put it into pPass
   end if
   
   put pUser into tSettings["username"]
   put pPass into tSettings["password"]
   put empty into xHeaders
   
   try
      tsnetinit
      put tsNetCustomSync(pServer, \
            "SELECT INBOX",xHeaders,retHeaders,retResult, \
            retBytes,tSettings) into tStat
      put tsNetCustomSync(pServer, \
            "UID SEARCH NOT SEEN",xHeaders,retHeaders, \
            retResult,retBytes,tSettings) into tStat
   catch tError
      answer error "ERROR: " & tError as sheet
      breakpoint
   end try
   
   put word 3 to -1 of tStat into tUIDs
   put the number of words in tUIDs into sMsgCount
   return retHeaders &cr& tStat &cr& sMsgCount
end IMAPGetHeaders

> On Mar 20, 2020, at 08:06 , Bob Sneidar via use-livecode 
> <[email protected]> wrote:
> 
> This may be of more use. No functional changes, just something you can use to 
> test against different IMAP servers:


_______________________________________________
use-livecode mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to