2
Daily email report
Question asked by Mike Mike - 1/3/2022 at 9:41 AM
Unanswered
Hi!
I'm facing an odd problem....
I find a way to have a daily report of total visits SINCE A CERTAIN DATE (website creation / smarterstats enabled).
Since I cannot find a way to publish public statistics, I had the idea to manage an attached csv to an email checked via a php script everyday then publish that "number of total visit since website creation TILL TODAY".

Any help (maybe a step by step...)

Many thanks

Mike

3 Replies

Reply to Thread
0
Mike Mike Replied
Anyone with some ideas?
1
Rod Strumbel Replied
I produce daily summaries via the API for our own internal reporting to our inhouse billing system.

pretty easy to do

vb.Net code below (nowhere near complete, but gives you the general idea)... should be able to easily be adapted into whatever language is your preference.

Add a Web Reference to SmarterMail.DomainAdmin and SmarterMail.UserAdmin

Public Class MailboxItem
    Public Property Name As String
    Public Property InCount As Long
    Public Property OutCount As Long
    Public Property InBytes As Long
    Public Property OutBytes As Long
    Public Property CurrentSize As Long

    Public Sub New(strName As String)
        Name = strName
        InCount = 0
        OutCount = 0
        InBytes = 0
        OutBytes = 0
        CurrentSize = 0
    End Sub
End Class

Dim theDomains As New List(Of String)
Dim theMailboxes As New List(Of MailboxItem)

'query to get list of domains
Dim domAdmin As New SmareterMail.DomainAdmin.svcDomainAdmin
Dim domListResult As SmarterMail.DomainAdmin.DomainListResult = domAdmin.GetAllDomains(adminUsername, adminPassword)

        If domListResult.Result = True Then
            For Each s As String In domListResult.DomainNames
                theDomains.Add(s)
            Next
        End If

'for each domain get list of mailboxes
For Each strDomain As String In theDomains
    Dim usrAdmin As New SmarterMail.UserAdmin.svcvUserAdmin
    Dim usrInfoListResult As SmarterMail.UserAdmin.UserInfoListResult =         usrAdmin.GetUsers(adminUsername, adminPassword, strDomain)
    If userInfoListResult.Result Then
        For Each obj As SmarterMail.UserAdmin.UserInfo In usrInfoListResults.Users
            Dim mb As New MailboxItem(obj.UserName)
            theMailboxes.Add(mb)
        Next
    End If
Next

'For each mailbox pull the stats
For Each mItem as MailboxItem in theMailboxes
    Dim usrAdmin As New SmarterMail.UserAdmin.svcUserAdmin
    Dim usrStatInfoResult As SmarterMail.UserAdmin.StatInfoResult =         
        usrAdmin.GetUserStats(
                adminUsername,             
                adminPassowrd, 
                mItem.Name, 
                CDate(strDate + " 00:00:00"), CDate(strDate + " 23:59:59"))

        If usrStatInfoResult.Result = True Then
            mItem.InCount = usrStatInfoResult.MessagesReceived
            mItem.OutCount = usrStatInfoResult.MessagesSent
            mItem.InBytes = usrStatInfoResult.BytesReceived
            mItem.OutBytes = usrStatInfoResult.BytesSent
            mItem.CurrentSize = usrStatInfoResult.BytesSize
        End If
Next

At that point the list of MailItems (theMailboxes) will contain the mailbox name, the In/Out counts and In/Out bytes size totals as well as the current size of the mailbox.  Loop thru it and dump into whatever form of reporting you prefer.

Hope that helps anyone who needs it




1
Rod Strumbel Replied
My mistake... I didn't see this was SmarterStats until after I posted the info.   The above is for SmarterMail... I would assume something similar to the above would work if they have an "svc" API for that product as well (what they call their Legacy API).   Just need the proper classes and hierarchy for that.

Reply to Thread