new Mail(agent, characterId, token)
Create a new Mail function for the character, including its SSO token.
Parameters:
| Name | Type | Description | 
|---|---|---|
agent | 
            
            ESIAgent | The ESI agent  | 
        
characterId | 
            
            Number | The id of the character whose mail is accessed  | 
        
token | 
            
            String | The SSO access token for the character  | 
        
Members
- 
    
labels :Labels
 - 
    
    
A Labels instance for this character, allowing access to the labels they have created.
Type:
 
Methods
- 
    
all()
 - 
    
    
Fetch all mails for the character as a single array. This makes multiple calls to inbox. Use with caution as certain characters could have substantial amounts of mail.
Returns:
- Type
 - Promise.<Array.<Object>>
 
 - 
    
cspaCost(toIds)
 - 
    
    
Takes a source character ID in the url and a set of target character ID's in the body, returns a CSPA charge cost.
This makes an HTTP POST request to
/characters/{character_id}/cspa/. The route version isv3.The route parameter,
characters, is built implicitly by the function. The function argumenttoIdsmaps to thecharactersproperty of thecharactersroute parameter. The array length oftoIdsmust be between1and100.On success, this resolves to aggregate cost of sending a mail from the source character to the target characters, in ISK hundredths. Note that the type schema of the response is modified from what is defined in ESI. Specifically, it returns only the
costproperty.This function must be used with an SSO token that has the following scopes:
esi-characters.read_contacts.v1
Parameters:
Name Type Description toIdsArray.<Number> Characters array.
Returns:
A Promise that resolves to cost integer.
- Type
 - Promise.<Number>
 
 - 
    
get(id)
 - 
    
    
Get a Message instance for the given message or mail id.
Parameters:
Name Type Description idThe message id
Returns:
- Type
 - Message
 
 - 
    
inbox(labelIds, lastMailId)
 - 
    
    
Return the 50 most recent mail headers belonging to the character that match the query criteria. Queries can be filtered by label, and last_mail_id can be used to paginate backwards. This route is cached for up to 30 seconds.
This makes an HTTP GET request to
/characters/{character_id}/mail/. The route version isv1.The array length of
labelIdsmust be between1and25.On success, this resolves to the requested mail. An example result is:
[ { "from": 90000001, "is_read": true, "labels": [ 3 ], "mail_id": 7, "recipients": [ { "recipient_id": 90000002, "recipient_type": "character" } ], "subject": "Title for EVE Mail", "timestamp": "2015-09-30T16:07:00Z" } ]This function must be used with an SSO token that has the following scopes:
esi-mail.read_mail.v1
Parameters:
Name Type Default Description labelIdsArray.<Number> Fetch only mails that match one or more of the given labels. If empty, no filtering is performed.
lastMailIdNumber 0 List only mail with an ID lower than the given ID, if present. If
0, the most recent mails are returned.Returns:
A Promise that resolves to the parsed JSON of the response.
- Type
 - Promise.<Array.<Object>>
 
 - 
    
lists()
 - 
    
    
Return all mailing lists that the character is subscribed to. This route is cached for up to 120 seconds.
This makes an HTTP GET request to
/characters/{character_id}/mail/lists/. The route version isv1.On success, this resolves to mailing lists. An example result is:
[ { "mailing_list_id": 1, "name": "test_mailing_list" } ]This function must be used with an SSO token that has the following scopes:
esi-mail.read_mail.v1
Returns:
A Promise that resolves to the parsed JSON of the response.
- Type
 - Promise.<Array.<Object>>
 
 - 
    
send(mail)
 - 
    
    
Create and send a new mail.
This makes an HTTP POST request to
/characters/{character_id}/mail/. The route version isv1.An example value for
mailis shown below:{ "approved_cost": 0, "body": "body string", "recipients": [ { "recipient_id": 0, "recipient_type": "" } ], "subject": "subject string" }On success, this resolves to the id of the created entity.
This function must be used with an SSO token that has the following scopes:
esi-mail.send_mail.v1
Parameters:
Name Type Description mailObject The mail to send. The mail descriptor
Returns:
A Promise that resolves to an id.
- Type
 - Promise.<Number>
 
 - 
    
unreadCount()
 - 
    
    
This makes a request to the
labelsroute and then filters the result to just return the total unread count.Return a list of the users mail labels, unread counts for each label and a total unread count. This route is cached for up to 30 seconds.
This makes an HTTP GET request to
/characters/{character_id}/mail/labels/. The route version isv3.On success, this resolves to a list of mail labels and unread counts. Note that the type schema of the response is modified from what is defined in ESI. Specifically, it returns only the
total_unread_countproperty.This function must be used with an SSO token that has the following scopes:
esi-mail.read_mail.v1
Returns:
A Promise that resolves to total_unread_count integer.
- Type
 - Promise.<Number>