Re: Custom categorizer recipients problems
From: Tom Delany (TomDelany_at_discussions.microsoft.com)
Date: 09/30/04
- Next message: Scott Phillips: "No IP address logging on internal email."
- Previous message: Lanwench [MVP - Exchange]: "Re: Not receiveing outside email"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 30 Sep 2004 13:59:10 -0700
I would really be interested in this sample code myself, but I can't seem to
find it attached anyhere.
Tom Delany
"Daniel Longley [MSFT]" wrote:
> While I'd have to do some debugging to figure out exactly why you're seeing
> that behavior, what I can tell you is that this is an unanticipated usage of
> the API. There is a right way to do what it sounds like you're trying to do
> though, and I've attached some sample code that hopefully can point you
> towards a solution.
>
> During categorization, there is already a new list (a la AllocNewList)
> available -- it's created automatically at the beginning of the
> categorization, and WriteList is called automatically at the end of the
> categorization. Consequently, at least one of the problems you're seeing is
> due to the fact that any list you write will be overwritten at the end of
> the categorization. So you need to get the pointer to the list that you're
> "supposed to" add to, and there is a correct way to do that (see how the
> sample code fetches it from the cat item).
>
> Even if you got this part working, if you're using Exchange you'd end up
> running into another series of problems stemming from the fact that if
> you're adding a new recipient then the new recipient needs to be categorized
> too, but it won't be categorized because of the way it's being added. For
> instance, if you're adding a DL's address, you'd expect the DL to be
> expanded, or if you're adding a mailbox recipient's address, you'd expect
> mail to be delivered to that mailbox, or if the recipient is a contact you'd
> expect MAPI messages to be encoded for that recipient in the proper format,
> and so on. All of these things depend on categorization.
>
> The categorizer gets its list of recipients to process from the message at
> the beginning of categorization, and additionally through a special API that
> you can call during categorization. Since you're adding a recipient once
> categorization has already started, you'll need to use that special API (see
> the sample code's usage of ResolveICategorizerItem) to see to it that your
> new recipient is also categorized. Since this is a feedback type of system,
> you need to pay special attention to avoid causing any loops, and you'll
> notice that a significant degree of the complexity in the sample code is
> devoted to handling some real looping conditions. (We're working on making
> this easier and more automatic in future versions of the categorizer so it
> doesn't have to be so much of a headache to do simple feedback forwarding.)
>
> Also, there's no need to commit here. The design of categorizer's use of
> mailmsg is such that a categorization can be "rolled back" and retried
> simply by throwing out everything in memory and reverting back to what was
> on disk at the time of submission of a message. If you commit partway
> through categorization, you're committing a message in an intermediate
> state, and not only does this hamper performance, but it can lead to
> incorrect behavior if a categorization ever needs to be retried for some
> reason, e.g. LDAP server temporarily unreachable, low memory conditions,
> service shutdown, etc. You'll notice that there aren't any calls to commit
> in the sample, and that is the right way to do it.
>
> Hope this helps!
>
> --
> Daniel Longley
> Exchange Transport Developer
> Microsoft Corporation
>
> ****** Disclaimer ******
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
> Note: Please do NOT reply to this e-mail address. It is used for newsgroup
> purposes only.
>
> "Tobias larsen" <tobias_vig_larsen@hotmail.com> wrote in message
> news:edk%23CdTeEHA.2376@tk2msftngp13.phx.gbl...
> > I'm having problems with a Categorizer SMTP event sink. On expanditem, i
> > need (among other things) modify the recipient list of the message. the
> code
> > i'm having problems with looks like the following :
> >
> > --------------------------------------------------------------------------
> --
> > ------------------------------------------------------------
> > --------------------------------------------------------------------------
> --
> > ------------------------------------------------------------
> > IMailMsgRecipientsAdd * pRecList;
> > IMailMsgRecipients * pRec;
> > IMailMsgProperties * pMsg;
> > ICategorizerMailMsgs * pMsgs;
> > ICategorizerItem * pCatItem;
> > .....
> >
> pCatItem->GetICategorizerMailMsgs(ICATEGORIZERITEM_ICATEGORIZERMAILMSGS,&pMs
> > gs);
> > pMsgs->GetMailMsg(0,&pMsg,&pRecAdd,&bCreated);
> >
> > if(pRec->AllocNewList(&pRecList)!=S_OK)throw new CFKException(0,"Failed to
> > alloc recip list");
> > szRecipName = "'zorb@borb.com";
> > if(pRecList->AddPrimary(1,(LPCSTR
> > *)&szRecipName,&dwPropID,&dwNewIndex,NULL,0)!=S_OK)throw new
> > CFKException(0,"Failed to add recip");
> > if(pRec->WriteList(pRecList)!=S_OK) throw new CFKException(0,"Failed to
> > write recip");
> > pMsg->Commit(NULL);
> > --------------------------------------------------------------------------
> --
> > ------------------------------------------------------------
> > --------------------------------------------------------------------------
> --
> > ------------------------------------------------------------
> >
> > As far as i understand the documentation, this should work. If, for
> example
> > the incoming mesage (pMsg) has three recipients, this should replace them
> > all with just the one recipient 'zorb@borb.com' Debug tells me that
> > recipient counts etc. are correct after the code has executed. What
> happens
> > is that the message is stuck in the queue until IISRESET, at which point
> it
> > is sent to the ORIGINAL recipient list.
> > This code is running asynchronously from the Categorizer ExpandItem event.
> > Help anyone ?
> >
> >
>
>
>
- Next message: Scott Phillips: "No IP address logging on internal email."
- Previous message: Lanwench [MVP - Exchange]: "Re: Not receiveing outside email"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|