Thread Tools Display Modes
08/06/19, 06:30 AM   #1
shAndrew
Join Date: Nov 2014
Posts: 3
Automatic ingame email sending with attachments question

Hi all.
Want to implement simple add-on with the following functionality:

From time to time I do Daily craft quests on both of my accounts. After Daily craft quests completed on each char on my second account, I want to send all the looted items to my main account (obviously except the bound items like crafting survey maps). I use Lazy Writ Crafter addon that unpacks all the loot from writ Containers so all of the items will be in chars inventory.

My flow would be the following:
1. Store all items on EVENT_LOOT_RECEIVED event (Filter these with IsItemBound, I guess)
2. Wait for all containers looted/opened
3. Trigger emailing part of this add-on.
4. Build up the email with attachments.
5. Send it with https://wiki.esoui.com/SendMail API func, I guess

Question is: Can you actually attach items to mail? If so - what function I can use to do that?
Also small question about 2nd step. What would be the best approach to wait for the 2nd step to be completed. Add-on will check account name and won't be executed if current account is my main account. Also assuming that all chars on 2nd account will be doing only writs, for now...

NOTE:
Have found these functions in API docs:
CanQueueItemAttachment(number Bag bagId, number slotIndex, number attachmentSlot)
Returns: boolean canAttach

QueueItemAttachment(number Bag bagId, number slotIndex, number attachmentSlot)
Returns: number itemAttachmentResult
Feeling these are what I need but not sure :/

Last edited by shAndrew : 08/06/19 at 06:48 AM. Reason: added NOTES
  Reply With Quote
08/06/19, 07:52 AM   #2
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,903
About adding attachments to the emails, maybe check my addon DoItAll in the folder src/AttachAll.
Mailer.lua is the mail stuff and attach.lua the attachments.
It recursively attaches items from the current filtered/shown inventory list (all inventory rows shown on the right side of the mail sent panel, having applied filters from search by text, other addons like FCOItemSaver, AdvancedFilters + plugins,...) until the mail is full, sends it then (if setting is enabled to do so) and redoes this until no items to attach are left.
You probably need something which works the same for your task then, except you won't send all items in the inventory list "filtered/shown currently" but only saved bagIds and slotIindices (except Craftbag bagId I guess if you use it, as it's account wide).

I hope it helps.
I think email sending "with attachments" is only available if you have opened the email scene if I remember correctly. But maybe It does work without opening the scene as well, but don't think so.
I think emails can be send with plain text only if you do not open the mail scene before (some collection addons like Lorebooks did this, maybe check it's code as well).

Oh and about the 2nd step:
If I remember correctly there is some global function within Dolgubons Lazy Writ Crafter which returns true if the box looting is currently in process. I've used this in my event_inventory_single_slot_update callback at the WishList addon.

Edit: After checking this have a look at WishList addon, function "WL.Inv_Single_Slot_Update" in file WishLis.lua, and there in lines 130ff.
There is no global function but an itemLink's flavorText shows if the containers are looted currently. I'm checking this, starting a RegisterForUpdate task to check every x milliseconds again and if the results say "nothing looted anymore from a container" the loot has been finished.

Maybe Dolgubon could provide a global function for this within DLWC addon, which would be very cool. Ask him I'd say and tell him there is at least 1 other addon which would benefit from it (WishList) :-)

Last edited by Baertram : 08/06/19 at 08:03 AM.
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » Automatic ingame email sending with attachments question

Thread Tools
Display Modes

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