Searching the mailbox

Hi,

I have a task that I need to be able todo, using C# is preffered ;)
- One is list all unread email messages from the inbox.

I've already got a working code to do this, but its terribly slow compared to using the GroupWise client.
In my own inbox, it takes roughly 1,5 seconds to list every unread email using the code below.
Using the builtin search, doing an advanced search using the same filters is instant.

            Console.Write("Mailserver #: ");
string sMailServer = Console.ReadLine();
string sCmdLine = "/*ipa*-mail" sMailServer "_whatever.whatever.whatever.no /ipp-1677";

Console.Write("Username: ");
sUserName = Console.ReadLine();
//Console.WriteLine("Brukernavn = " sUserName);

Console.Write("Password: ");
//sPassword = Console.ReadLine();
sPassword = ReadPassword();
Console.WriteLine("");
//Console.WriteLine("Passord = " sPassword);
Console.WriteLine("MessageFilter: " sMessageFilter);
Stopwatch sw = new Stopwatch();
sw.Start();

//GroupwareTypeLibrary.Application5 objGWSession = new GroupwareTypeLibrary.Application5();
GroupwareTypeLibrary.Application5 objGWSession = new GroupwareTypeLibrary.Application5();
GroupwareTypeLibrary.Account objAccount = default(GroupwareTypeLibrary.Account);


try
{
objAccount = objGWSession.MultiLogin(sUserName, sCmdLine, sPassword, sWhenToPromp, sReserved);
}
catch (Exception ex)
{
Console.WriteLine("Error in login: " ex.Message);
System.Environment.Exit(1);
}

Console.WriteLine("Eier av Postkasse = " objAccount.Owner.DisplayName);

int i = 0;

try
{
//GroupwareTypeLibrary.MessageList mesList = objAccount.AllMessages.Find(sMessageFilter);
GroupwareTypeLibrary.MessageList mesList = objAccount.MailBox.FindMessages(sMessageFilter);
foreach (GroupwareTypeLibrary.Message message in mesList)
{
string msg = message.Subject.PlainText;
string msgfrom = message.Sender.DisplayName.ToString();

//string sStartDate = dtEndDate.ToString();
//string sEndDate = dtEndDate.ToString();

//Console.WriteLine("");
//Console.WriteLine("Fra: " msgfrom);
//Console.WriteLine("Emne: " msg);
i ;
}
}
catch (Exception ex)
{
Console.WriteLine("Error in messagelist: " ex.Message);
Console.WriteLine("Error in messagelist: " ex.InnerException);
System.Environment.Exit(1);
}
Console.WriteLine("");
sw.Stop();
Console.WriteLine("Unread emails = " i);
Console.WriteLine("In milliseconds: {0}", sw.ElapsedMilliseconds);
Console.WriteLine("Done, press any key to continue...");
Console.Read();
objGWSession.Quit();


On my largest GroupWise user, this operation takes upwards to 60 seconds todo ( 70K emails to go through, around 600 unread)
When we use the GroupWise client, this takes 2 seconds.
Note: All our clients are set to online and doesnt cache locally.
(I need to extract the header of the email aswell as the sender too, but commented out for this sample)

What I've seen on the servers when we use the Object API todo this, is that it takes a while without any response on the client side, but at the server side the CPU load goes up 30-40% before sending the list over email's to the client.

I havent seen this when the normal client is used to the same extent.


Any ideas on how I can speed this up? I dont think I am pointing it to the actual inbox, since it also takes some emails outside of this, maybe thats an error too?

(We've already got a solution like this by using SOAP, but thats even slower then using this method, even with dedicated PO's)
  • I'm not going to be able to help you much.

    Keep in mind that the GWClient has been highly
    optimized over 25 years.

    The GWClient has a virtual list control that
    tracks loading of the items. It presents a page
    full, then in the background loads the data.
    It only reads in the data as needed. It loads
    just the fields needed for the columns. It doesn't
    load all of the data until the user opens an item.
    It doesn't read an attachment until the user opens
    it.

    Logistically, I'm not able to expose the virtual
    list control in SOAP.

    The GWClient caches a lot of information. It also
    employs various background threads to get the
    data.

    It only reads the data once (or again if there is
    a need).

    SOAP can never be as fast of the GWClient since SOAP
    is inherently slower.

    I'll not be able to help increase the performance of
    the Object API.

    I can do some with SOAP.

    In 8.0.2, I exposed getting the id's as sid's (short
    identifiers). These are the id's that the GWClient
    uses. Unfortunately, I can't expose all of the logic
    associated with sid's since the SOAP environment is
    not as secure of and access as with the GWClient, so
    I have to do extra validation of the access of the
    SOAP client.

    You can also improve the accessing of items based on
    what you specify in the view and in the filter. You
    have to do various timings to see what is optimal
    for your data.

    You can also use cursors to read the data in SOAP.

    >>> On Thursday, December 03, 2009 at 4:46 AM,

    theflyingcorpse<theflyingcorpse@no-mx.forums.novell.com> wrote:

    > Hi,
    >
    > I have a task that I need to be able todo, using C# is preffered ;)
    > ‑ One is list all unread email messages from the inbox.
    >
    > I've already got a working code to do this, but its terribly slowcompared

    to
    > using the GroupWise client.
    > In my own inbox, it takes roughly 1,5 seconds to list every unread
    > email using the code below.
    > Using the builtin search, doing an advanced search using the same
    > filters is instant.
    >
    >
    > Code:
    > ‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑
    > Console.Write("Mailserver #: ");
    > string sMailServer = Console.ReadLine();
    > string sCmdLine = "/*ipa*‑mail" sMailServer

    "_server.baerum.kommune.no
    > /ipp‑1677";
    >
    > Console.Write("Username: ");
    > sUserName = Console.ReadLine();
    > //Console.WriteLine("Brukernavn = " sUserName);
    >
    > Console.Write("Password: ");
    > //sPassword = Console.ReadLine();
    > sPassword = ReadPassword();
    > Console.WriteLine("");
    > //Console.WriteLine("Passord = " sPassword);
    > Console.WriteLine("MessageFilter: " sMessageFilter);
    > Stopwatch sw = new Stopwatch();
    > sw.Start();
    >
    > //GroupwareTypeLibrary.Application5 objGWSession = new
    > GroupwareTypeLibrary.Application5();
    > GroupwareTypeLibrary.Application5 objGWSession = new
    > GroupwareTypeLibrary.Application5();
    > GroupwareTypeLibrary.Account objAccount =
    > default(GroupwareTypeLibrary.Account);
    >
    >
    > try
    > {
    > objAccount = objGWSession.MultiLogin(sUserName, sCmdLine, sPassword,
    > sWhenToPromp, sReserved);
    > }
    > catch (Exception ex)
    > {
    > Console.WriteLine("Error in login: " ex.Message);
    > System.Environment.Exit(1);
    > }
    >
    > Console.WriteLine("Eier av Postkasse = "

    objAccount.Owner.DisplayName);
    >
    > int i = 0;
    >
    > try
    > {
    > //GroupwareTypeLibrary.MessageList mesList =
    > objAccount.AllMessages.Find(sMessageFilter);
    > GroupwareTypeLibrary.MessageList mesList =
    > objAccount.MailBox.FindMessages(sMessageFilter);
    > foreach (GroupwareTypeLibrary.Message message in mesList)
    > {
    > string msg = message.Subject.PlainText;
    > string msgfrom = message.Sender.DisplayName.ToString();
    >
    > //string sStartDate = dtEndDate.ToString();
    > //string sEndDate = dtEndDate.ToString();
    >
    > //Console.WriteLine("");
    > //Console.WriteLine("Fra: " msgfrom);
    > //Console.WriteLine("Emne: " msg);
    > i ;
    > }
    > }
    > catch (Exception ex)
    > {
    > Console.WriteLine("Error in messagelist: " ex.Message);
    > Console.WriteLine("Error in messagelist: " ex.InnerException);
    > System.Environment.Exit(1);
    > }
    > Console.WriteLine("");
    > sw.Stop();
    > Console.WriteLine("Unread emails = " i);
    > Console.WriteLine("In milliseconds: {0}", sw.ElapsedMilliseconds);
    > Console.WriteLine("Done, press any key to continue...");
    > Console.Read();
    > objGWSession.Quit();
    >
    > ‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑
    >
    >
    > On my largest GroupWise user, this operation takes upwards to 60
    > seconds todo ( 70K emails to go through, around 600 unread)
    > When we use the GroupWise client, this takes 2 seconds.
    > Note: All our clients are set to online and doesnt cache locally.
    > (I need to extract the header of the email aswell as the sender too,
    > but commented out for this sample)
    >
    > What I've seen on the servers when we use the Object API todo this, is
    > that it takes a while without any response on the client side, but at
    > the server side the CPU load goes up 30‑40% before sending the list

    over
    > email's to the client.
    >
    > I havent seen this when the normal client is used to the same extent.
    >
    >
    > Any ideas on how I can speed this up? I dont think I am pointing it to
    > the actual inbox, since it also takes some emails outside of this, maybe
    > thats an error too?
    >
    > (We've already got a solution like this by using SOAP, but thats even
    > slower then using this method, even with dedicated PO's)


  • I could be missing something obvious, but, have you checked out the
    Account.GetQuickMessagesCollection() method? The QuickMessage objects in
    the return collection have a boolean Read property so you can check to see
    if users have accessed the message but the egwNewMessages option does some
    preliminary filtering to reduce the collection size. The QuickMessage
    object also exposes the key message properties and allows access to the
    underlying message object. I suspect the GroupWise client uses this under
    the hood.

    Here is the relevant documentation snippett.
    Account.GetQuickMessagesCollection(Date StartDate,
    QuickMessagesCreationConstants eHowBuildList)

    The eHowBuildList parameter controls which message items are included in the
    collection. The following values are possible for eHowBuildList:

    egwNewMessages Messages items in this account that were created or received
    only since the StartDate parameter are included

    egwModifiedMessages Message items in this account that have been changed
    only since the StartDate parameter are included

    egwAllMessages Every message item in this account is added to the
    QuickMessages collection, and the StartDate parameter is ignored.



    The QuickMessages collection should return message items quicker than other
    ways (such as the AllMessages collection or querying objects with their
    message lists). It is very fast when returning new messages, but retrieving
    modified messages is somewhat slower.



    Dave M



    "theflyingcorpse" <theflyingcorpse@no-mx.forums.novell.com> wrote in message
    news:theflyingcorpse.42m9qp@no-mx.forums.novell.com...
    >
    > Hi,
    >
    > I have a task that I need to be able todo, using C# is preffered ;)
    > - One is list all unread email messages from the inbox.
    >
    > I've already got a working code to do this, but its terribly slow
    > compared to using the GroupWise client.
    > In my own inbox, it takes roughly 1,5 seconds to list every unread
    > email using the code below.
    > Using the builtin search, doing an advanced search using the same
    > filters is instant.
    >