Search The ForumSearch   RegisterRegister  LoginLogin

AfterLogic WebMail Pro

 AfterLogic Forum : AfterLogic WebMail Pro
Subject Topic: How to count unread emails PHP Api? Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
glenelkins
Newbie
Newbie


Joined: 25 August 2020
Location: United Kingdom
Online Status: Offline
Posts: 2
Posted: 16 October 2020 at 3:28am | IP Logged Quote glenelkins

The documentation on the PHP api is not very clear, i'm looking for a way to be able to get a count of all unread emails across all accounts if logging in as super admin.
Back to Top View glenelkins's Profile Search for other posts by glenelkins
 
Igor
AfterLogic Support
AfterLogic Support


Joined: 24 June 2008
Location: United States
Online Status: Offline
Posts: 5489
Posted: 16 October 2020 at 4:44am | IP Logged Quote Igor

Something like this should do it.

Code:
include './system/autoload.php';
\Aurora\System\Api::Init(true);
$oCoreModule = \Aurora\System\Api::GetModule("Core");
$oMailModule = \Aurora\System\Api::GetModule("Mail");

$ul = $oCoreModule->getUserList();
$ulItems = $ul["Items"];

foreach ($ulItems as $key=>$item) {
     $sEmail = $item["PublicId"];
     $oUser = $oCoreModule->GetUserByPublicId($sEmail);
     $iUserId = $oUser->EntityId;
     $oAccount = $oCoreModule->GetAccountUsedToAuthorize($sEmail);
     $iAcctId = $oAccount->EntityId;
     $aFolders = $oMailModule->GetRelevantFoldersInformation( $iAcctId, array("INBOX"), true);
     echo "<p><b>".$sEmail."</b><br />Total: ".$aFolders["Counts"]["INBOX"][0]."<br />Unread: ".$aFolders["Counts"]["INBOX"][1]."</p>";
}


Hope this helps. We'll probably add this sample to Developer's Guide section of the documentation.

UPDATE 22 October 2020:

This sample is now available in the product documentation at:

Getting number of unread mails in user accounts

--
Regards,
Igor, Afterlogic Support
Back to Top View Igor's Profile Search for other posts by Igor
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump

Powered by Web Wiz Forums version 7.9
Copyright ©2001-2004 Web Wiz Guide