Skip to main content
Version: 6.0.0

ReadAllMail

public BackndReturnObject ReadAllMail(MailType mailType);

caution

This method loads only mail registered in the mail list.
Before using the method, we recommend you update the list by loading the mail list with Mail.GetMailList in advance.

Parameter

ValueTypeDescription
mailTypeMailTypeType of mail to claim all

MailType

ValueDescription
AdminAdmin mail sent from BACKND Console
RankRanking mail sent automatically after ranking settlement
CouponCoupon mail sent after using a coupon with the page created in Web Coupon Settings in BACKND Console
UserUser mail sent using each user's data

Description

Claims all mail in the list of the given mailType.

  • The data types "S", "L", and "M" in the return values of the previous mail function(Backnd.Player.Post) was removed.
  • You may use the same logic for claiming admin, ranking, and coupon mail, as they all have the same return values when claimed.
  • An error occurs if there is no mail to claim.

Example

Synchronous

var  bro = Backnd.Mail.ReadAllMail(MailType.Admin);

// For the logic to claim all mail, please refer to the 'Sample code.'

Asynchronous

Backnd.Mail.ReadAllMail(MailType.Admin, callback => {
// For the logic to claim all mail, please refer to the 'Sample code.'
});

Return cases

Success cases

When the lookup is successful
statusCode : 200

returnValue : refer to GetReturnValuetoJSON

Error cases

When there is no more mail to claim statusCode : 404
errorCode : NotFoundException

GetReturnValuetoJSON

{
"postItems": [
[], // When there are no items attached
[
{
"item": { // When there is one item attached(Ranking mail only allows one item to be attached.)
"chartFileName": "chartExample.xlsx",
"itemID": "i101",
"itemName": "Item111",
"hpPower": "1",
"aabab": "1"
},
"itemCount": 1,
"chartName": "DataTable"
}
],
[
{
"item": { // When there are multiple items attached
"chartFileName": "chartExample.xlsx",
"itemID": "i101",
"itemName": "Item111",
"hpPower": "1",
"aabab": "1"
},
"itemCount": 1,
"chartName": "DataTable"
},
{
"item": {
"chartFileName": "itemTable.xlsx",
"itemID": "item-2392",
"itemName": "Longsword"
},
"itemCount": 1,
"chartName": "Item"
}
]
]
}

Sample code

public class ReceiveItem {
public string chartFileName;
public string itemID;
public string itemName;
public int hpPower;
public int itemCount;

public override string ToString() {
return $"chartFileName:{chartFileName}\n" +
$"itemID:{itemID}\n" +
$"itemName:{itemName}\n" +
$"hpPower:{hpPower}\n" +
$"itemCount:{itemCount}\n";
}
}
public void ReadAllMailTest() {

BackndReturnObject bro = Backnd.Mail.GetMailList(MailType.Admin, 100);

if(bro.IsSuccess() == false) {
Debug.Log("An error occurred while loading the mail.");
return;
}

var receiveBro = Backnd.Mail.ReadAllMail(MailType.Admin);

if(receiveBro.IsSuccess() == false) {
Debug.LogError("An error occurred while claiming all mail. : " + receiveBro);
return;
}

foreach(BACKND.LitJson.JsonData postItemJson in receiveBro.GetReturnValuetoJSON()["postItems"]) {

for(int j = 0; j < postItemJson.Count; j++) {
if(!postItemJson[j].ContainsKey("item")) {
continue;
}

ReceiveItem item = new ReceiveItem();
if(postItemJson[j]["item"].ContainsKey("itemName")) {
item.itemName = postItemJson[j]["item"]["itemName"].ToString();
}

// chartFileName does not exist for ranking rewards.
if(postItemJson[j]["item"].ContainsKey("chartFileName")) {
item.chartFileName = postItemJson[j]["item"]["chartFileName"].ToString();
}

if(postItemJson[j]["item"].ContainsKey("itemID")) {
item.itemID = postItemJson[j]["item"]["itemID"].ToString();
}

if(postItemJson[j]["item"].ContainsKey("hpPower")) {
item.hpPower = int.Parse(postItemJson[j]["item"]["hpPower"].ToString());
}

if(postItemJson[j].ContainsKey("itemCount")) {
item.itemCount = int.Parse(postItemJson[j]["itemCount"].ToString());
}

Debug.Log(item.ToString());
}
}
}