Thread Tools Display Modes
04/13/14, 01:03 PM   #1
Dio
 
Dio's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 29
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())

Last edited by Dio : 04/13/14 at 01:06 PM.
  Reply With Quote
04/25/14, 05:54 AM   #2
Teli
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 19
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
  Reply With Quote
04/25/14, 06:09 PM   #3
Teli
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 19
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
  Reply With Quote

ESOUI » Developer Discussions » General Authoring Discussion » Deleting or returning mail - doesn't work?


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off