In this section you will learn how to manage the in-game inbox of the local user.
Loading Messages
To retrieve the list of messages of a user you need to call the Message.Load:
Mail.Load(
eMailList.Received, 1, 3, (Mail[] messages,
int count,
int pagesCount,
string error) => {
if (string.IsNullOrEmpty(error))
Debug.Log("Success: " + messages.Length);
else
Debug.Log("Failed: " + error);
});
eMailList
Mail list.
Definition: CombuEnums.cs:28
Sending Messages
To send a new message to a user you need to call one of the overloads of Mail.Send:
Mail.Send(123, "Subject", "Message body", false, (bool success, string error) => {
if (success)
Debug.Log("Success");
else
Debug.Log("Failed: " + error);
});
Mail.Send("user1", "Subject", "Message body", false, (bool success, string error) => {
if (success)
Debug.Log("Success");
else
Debug.Log("Failed: " + error);
});
Mail.Send( new long[] { 123, 456 }, "Subject", "Message body", false, (bool success, string error) => {
if (success)
Debug.Log("Success");
else
Debug.Log("Failed: " + error);
});
Mail.Send( new string[] { "user1", "user2" }, "Subject", "Message body", false, (bool success, string error) => {
if (success)
Debug.Log("Success");
else
Debug.Log("Failed: " + error);
});
Sending to UserGroup
If you want to send a message to a UserGroup then you need to call Mail.SendMailToGroup:
Mail.SendMailToGroup(123, "Subject", "Message body", false, (bool success, string error) => {
if (success)
Debug.Log("Success");
else
Debug.Log("Failed: " + error);
});
Marking Messages as Read
To mark a message as Read you need to call Mail.Read, or call the method Read on a Mail instance:
Mail.Read( new long[] { 123, 456 }, new long[0], (bool success, string error) => {
if (success)
Debug.Log("Success");
else
Debug.Log("Failed: " + error);
});
Mail.Read( new long[0], new long[] { 123, 456 }, (bool success, string error) => {
if (success)
Debug.Log("Success");
else
Debug.Log("Failed: " + error);
});
myMail.Read( (bool success, string error) => {
if (success)
Debug.Log("Success");
else
Debug.Log("Failed: " + error);
});
Marking Messages as Unread
To mark a message as Unread you need to call Mail.Unread, or call the method Unread on a Mail instance:
Mail.Unread( 123, (bool success, string error) => {
if (success)
Debug.Log("Success");
else
Debug.Log("Failed: " + error);
});
myMail.Unread( (bool success, string error) => {
if (success)
Debug.Log("Success");
else
Debug.Log("Failed: " + error);
});
Removing Items
To delete a message you need to call Message.Delete, or call the method Delete on a Mail instance:
Mail.Delete(123, (bool success, string error) => {
if (success)
Debug.Log("Success");
else
Debug.Log("Failed: " + error);
});
myMail.Delete( (bool success, string error) => {
if (success)
Debug.Log("Success");
else
Debug.Log("Failed: " + error);
});
Loading Conversations
To load the list of discussions of the local user with others you can call Mail.LoadConversations, it will fill an ArrayList with objects of type User or UserGroup (based on the idGroup associated to the Mail object):
Mail.LoadConversations( (ArrayList conversations, int count, string error) => {
if (string.IsNullOrEmpty(error))
Debug.Log("Success: " + conversations.Count);
else
Debug.Log("Failed: " + error);
});
Counting Messages
To count the messages in the inbox of the local user you can call Mail.Count:
Mail.Count( new long[] { 123, 456 }, new long[0], (MailCount[] counts, string error) => {
if (string.IsNullOrEmpty(error))
Debug.Log("Success: " + counts.Length);
else
Debug.Log("Failed: " + error);
});
Mail.Count( new long[0], new long[] { 123, 456 }, (MailCount[] counts, string error) => {
if (string.IsNullOrEmpty(error))
Debug.Log("Success: " + counts.Length);
else
Debug.Log("Failed: " + error);
});