ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   General Authoring Discussion (https://www.esoui.com/forums/forumdisplay.php?f=174)
-   -   Deleting or returning mail - doesn't work? (https://www.esoui.com/forums/showthread.php?t=844)

Dio 04/13/14 01:03 PM

Deleting or returning mail - doesn't work?
 
It doesn't look like the API functions ReturnMail or DeleteMail (with or without the 2nd argument) do anything, is this intended to prevent addons from removing mail?

e.g. ReturnMail(GetNextMailId()) or DeleteMail(GetNextMailId())

Teli 04/25/14 05:54 AM

I found that the mailbox needs to be open and the mail has to have been read. try adding
Code:

RequestReadMail(mailId)
before your code. The other issue I found is you need to wait for a response back from the event
Code:

EVENT_MAIL_NUM_UNREAD_CHANGED
before it takes effect

Teli 04/25/14 06:09 PM

try this code you have to queue them all up first. Then when you process the code it fires the first delete event. The event will keep triggering mailOpen.ProcessDelQueue() until it runs out of entries in the table.

Lua Code:
  1. function mailOpen.QueueDelete(mailId,forceDelete)
  2.     table.insert(delQueue,{['mailId']=mailId,['forceDelete']=forceDelete})
  3. end
  4. function mailOpen.ProcessDelQueue()
  5.     if delQueue[1].mailId ~= nil then
  6.         --d(delQueue[1].mailId)
  7.         DeleteMail(delQueue[1].mailId,delQueue[1].forceDelete)
  8.         table.remove(delQueue,1)
  9.     end
  10. end
  11.  
  12.  
  13. function mailOpen.Test()
  14.     for k, v in pairs(mailOpen.mailInfo) do
  15.             if v.unread then RequestReadMail(v.mailId) end
  16.             mailOpen.QueueDelete(v.mailId,false)
  17.     end
  18.     mailOpen.ProcessDelQueue()
  19. end
  20.  
  21. --EVENT_MAIL_REMOVED
  22. function mailOpen.MailRemoved(eventCode, mailId)
  23.     mailOpen.ProcessDelQueue()
  24.     d('mail deleted')
  25. end


All times are GMT -6. The time now is 03:39 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI