Skip to main content
Version: 6.0.0

GetMailList(MailType.Admin)

public BackndMailReturnObject GetMailList(MailType.Admin);
public BackndMailReturnObject GetMailList(MailType.Admin, int limit);

BackndMailReturnObject

GetReturnValueByMailItemList(MailType mailType)

If an error occurred, null is returned.

BackndMailReturnObject bro = Backnd.Mail.GetMailList(MailType.Admin, 10);

foreach(BackndMailItem item in bro.GetReturnValueByMailItemList(MailType.Admin)) {
Debug.Log(item.ToString());
}

BackndMailItem

public class BackndMailItem
{
public MailType postType;
public string title = string.Empty;
public string content = string.Empty;
public string expirationDate = string.Empty;
public string reservationDate = string.Empty;
public string sentDate = string.Empty;
public string nickname = string.Empty;
public string inDate = string.Empty;
public string author = string.Empty;
public string rankType = string.Empty;
public List<BackndMailContentItem> items = new List<BackndMailContentItem>();
}

public class BackndMailContentItem
{
public string chartFileName = string.Empty;
public string chartName = string.Empty;
public Dictionary<string, string> itemInfo = new Dictionary<string, string>();
public string itemCount = string.Empty;
}

Parameters

ValueTypeDescription
mailTypeMailTypeType of mail to load
limitintNumber of mail to load. Choose between 10 and 100. The limit is set to 10 by default.

'limit' evaluates to 10 if you specify a smaller number.

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

Loads the mail list of the given type(MailType).

The return value varies for each MailType, so please refer to GetReturnValuetoJSON() below.

Note that user mail has vastly different JSON type from admin or ranking mail.

  • The data types "S", "L", and "M" in the return values of the previous mail function(Backnd.Player.Post) was removed.
  • Every mail has an expiration date according to its type, after which the mail gets deleted from the list.
  • The user who loaded the mail is marked as 'Unclaimed' on the Mail Management page of the console. When claimed, the date is overwritten.
  • Items that are attached to admin mail are automatically removed after the user claims them.
  • The mail expiration date can be set in BACKND Console.(Within a day - 1 hour, 3 hours, 6 hours, 12 hours, 24 hours, 7 days, 15 days, or 30 days)

Multilingual support

  • If the user's country code is present and mail is registered in the console for that country → Returns the title and the content of that country's mail.
  • If the user's country code is not present, or if an event is not registered for the country in the console → Returns the default title and content.

Example

Synchronous

BackndMailReturnObject bro = Backnd.Mail.GetMailList(MailType.Admin, 10);

foreach(BackndMailItem item in bro.GetReturnValueByMailItemList(MailType.Admin)) {
Debug.Log(item.ToString());
Debug.Log("Title : " item.title);
Debug.Log("itemInfo : " + item.items[0].Keys);
}

Asynchronous

Backnd.Mail.GetMailList(MailType.Admin, 10, callback => {
BACKND.LitJson.JsonData json = callback.GetReturnValuetoJSON()["postList"];

for(int i = 0; i < json.Count; i++) {
Debug.Log("Title : " + json[i]["title"].ToString());
Debug.Log("inDate : " + json[i]["inDate"].ToString());
}
});

Return cases

Success cases

When mail is loaded successfully
statusCode : 200

returnValue : refer to GetReturnValuetoJSON

When there is no mail to load
statusCode : 200

returnValue : { "postList" : []}

GetReturnValuetoJSON

Admin mail

When parsing, note that the admin mail can have zero, one, or multiple items.

{
"postList": [
{
"content": "Content", // Content of the mail sent from the console
"expirationDate": "2021-12-21T10:32:11.021Z", // Mail expiration date
"reservationDate": "2021-12-20T10:32:11.021Z", // Mail registration date
"nickname": "IAmUser1", // Sender's nickname
"inDate": "2021-12-20T10:32:11.021Z", // Mail's inDate
"title": "0 items", // Mail title
"author": "Admin", // Mail sender
"sentDate": "2021-12-20T10:32:11.021Z", // Sent date
"items": [] // Item attached to the mail(0 items in this case)
},
{
"content": "This mail has 1 item",
"expirationDate": "2021-12-21T10:33:27.711Z",
"reservationDate": "2021-12-20T10:33:27.711Z",
"nickname": "IAmUser1",
"inDate": "2021-12-20T10:33:27.711Z",
"title": "Sending 1 item only",
"author": "GM Launcher",
"sentDate": "2021-12-20T10:33:27.711Z",
"items": [ // Item information
{
"item": {
"chartFileName": "item-chart.xlsx",
"itemID": "i101",
"itemName": "Item1",
"hpPower": "1"
},
"itemCount": 1,
"chartName": "DataTable"
}
]
},
{
"content": "This mail has 3 items",
"expirationDate": "2021-12-21T10:32:52.615Z",
"reservationDate": "2021-12-20T10:32:52.615Z",
"nickname": "IAmUser1",
"inDate": "2021-12-20T10:32:52.615Z",
"title": "Sending 3 items",
"author": "GM BACKND",
"sentDate": "2021-12-20T10:32:52.615Z",
"items": [
{
"item": {
"chartFileName": "item-chart.xlsx",
"itemID": "i101",
"itemName": "Item1",
"hpPower": "1"
},
"itemCount": 100,
"chartName": "DataTable"
},
{
"item": {
"chartFileName": "item-chart.xlsx",
"itemID": "i102",
"itemName": "Item2",
"hpPower": "2"
},
"itemCount": 20000
},
{
"item": {
"chartFileName": "item-chart.xlsx",
"itemID": "i103",
"itemName": "Item303",
"hpPower": "3"
},
"itemCount": 3,
"chartName": "DataTable"
}
]
}
]
}

Sample code

This example works for admin, ranking, and coupon mail.

public class MailDataTableItem {
public string chartFileName;
public string itemID;
public string itemName;
public string hpPower;
public int itemCount;
public override string ToString() {
return
"item : \n" +
$"| chartFileName : {chartFileName}\n" +
$"| itemID : {itemID}\n" +
$"| itemName : {itemName}\n" +
$"| itemCount : {itemCount}\n" +
$"| hpPower : {hpPower}\n";
}
}
public class MailItem {
public MailType mailType;
public string title;
public string content;
public DateTime expirationDate;
public DateTime reservationDate;
public DateTime sentDate;
public string nickname;
public string inDate;
public string author; // Exists only in admin mail
public string rankType; // Exists only in ranking mail
public List<MailDataTableItem> items = new List<MailDataTableItem>();
public override string ToString() {
string totalString =
$"title : {title}\n" +
$"inDate : {inDate}\n";
if(mailType == MailType.Admin || mailType == MailType.Rank) {
totalString +=
$"content : {content}\n" +
$"expirationDate : {expirationDate}\n" +
$"reservationDate : {reservationDate}\n" +
$"sentDate : {sentDate}\n" +
$"nickname : {nickname}\n";
if(mailType == MailType.Admin) {
totalString += $"author : {author}\n";
}
if(mailType == MailType.Rank) {
totalString += $"rankType : {rankType}\n";
}
}
string itemList = string.Empty;
for(int i = 0; i < items.Count; i++) {
itemList += items[i].ToString();
itemList += "\n";
}
totalString += itemList;
return totalString;
}
}
public void GetMailListTest() {
int limit = 100;
MailType mailType = MailType.Admin;
BackndMailReturnObject bro = Backnd.Mail.GetMailList(mailType, limit);
if(!bro.IsSuccess()) {
Debug.LogError(bro.ToString());
return;
}
BACKND.LitJson.JsonData postListJson = bro.GetReturnValuetoJSON()["postList"];

List<MailItem> postItemList = new List<MailItem>();

for(int i = 0; i < postListJson.Count; i++) {

MailItem postItem = new MailItem();

postItem.inDate = postListJson[i]["inDate"].ToString();
postItem.title = postListJson[i]["title"].ToString();
postItem.mailType = mailType;

if(mailType == MailType.Admin || mailType == MailType.Rank) {
postItem.content = postListJson[i]["content"].ToString();
postItem.expirationDate = DateTime.Parse(postListJson[i]["expirationDate"].ToString());
postItem.reservationDate = DateTime.Parse(postListJson[i]["reservationDate"].ToString());
postItem.nickname = postListJson[i]["nickname"]?.ToString();
postItem.sentDate = DateTime.Parse(postListJson[i]["sentDate"].ToString());

if(postListJson[i].ContainsKey("author")) {
postItem.author = postListJson[i]["author"].ToString();
}
if(postListJson[i].ContainsKey("rankType")) {
postItem.author = postListJson[i]["rankType"].ToString();
}
}
if(postListJson[i]["items"].Count > 0) {

for(int itemNum = 0; itemNum < postListJson[i]["items"].Count; itemNum++) {

MailDataTableItem item = new MailDataTableItem();
item.itemCount = int.Parse(postListJson[i]["items"][itemNum]["itemCount"].ToString());
item.chartFileName = postListJson[i]["items"][itemNum]["item"]["chartFileName"].ToString();
item.itemID = postListJson[i]["items"][itemNum]["item"]["itemID"].ToString();
item.itemName = postListJson[i]["items"][itemNum]["item"]["itemName"].ToString();
item.hpPower = postListJson[i]["items"][itemNum]["item"]["hpPower"].ToString();

postItem.items.Add(item);
}
}

postItemList.Add(postItem);
Debug.Log(postItem.ToString());
}
}