Redemption Inbox problem + instability

M

mirzoni

I have an app that uses redemption and mapi to access the emails in a
exchange mailbox.

Redemption:
Dim FolderItemsREDInbox As Redemption.RDOFolder
FolderItemsREDInbox = session.GetDefaultFolder(6)
(loads OK)

mapi:
Dim Folder As Outlook.MAPIFolder = oNS.GetDefaultFolder(6)
Dim FolderItems As Outlook.Items = Folder.Items
(also loads OK)

(note that both are pointing to the Inbox)
however, then i do the following:

Dim HowManyItemsREDInbox As Integer
HowManyItemsREDInbox = FolderItemsRED.Items.Count
i get: HowManyItemsREDInbox = 25

and
Dim HowManyItemsMAPIInbox As Integer
HowManyItemsMAPIInbox = FolderItems.Count
i get: HowManyItemsMAPIInbox = 50

how can this be? this is really mesing up some things for me over here
:(

ALSO:
when I load 500+ items redemptions becomes unstable by errors occurrin
randomly.
( as per recommendations on the official redemption site i have used:
I have used a global var for the redemption instance
+
i have MS Outlook 2003 SP3 (11.6568.6568 version)
)

can anyone out there shed some light on these two issues?

Regard
 
D

Dmitry Streblechenko

What is the real item count as reported by Outlook itself? Are you sure both
Redemption and Outlook are using the same MAPI profile?
Since you are using .Net, most likely you are running out of the 255 RPC
channels limit imposed by Exchange. .Net does not immediately release COM
objects, you need to do that explicitly using Marshal.ReleaseCOMObject() in
the loop. Avoid using multiple "." notation to make sure there are no
implicit variables created by the compiler.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
M

mirzoni

Hi Dmitry,

Thanks for you reply!
The actual numbers are:
MAPI:6310
REDEMPTION:630
 
D

Dmitry Streblechenko

1.What does Outlook show for that folder?
2. Are you sure you end up using the same MAPI profile?
3. Are both cases online or cached?
4. What happens if instead of calling RDOSession.Logon you set
RDOSession.MAPIOBJECT ot Session.RDOSession from CDO?

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
M

mirzoni

Hi Dmitri,

Thanks for you reply!

I am not sure what do you mean by:
4. What happens if instead of calling RDOSession.Logon you set
RDOSession.MAPIOBJECT ot Session.RDOSession from CDO?

here is what I run to get to the information:


'...logging on exchange...


'redemption
Dim session As New Redemption.RDOSession
session = CreateObject("Redemption.RDOSession")
session.LogonExchangeMailbox(MailBoxName, Server)

Dim FolderItemsRED As Redemption.RDOFolder
FolderItemsRED = session.GetDefaultFolder(6)

dim redcount as integer
redcount = FolderItemsRED.Items.Count
'this gives me 11


'mapi
Dim outlook_Profile As String = MailBoxName
Dim oSession As New MAPI.Session
oApp = New Outlook.Application
oNS = oApp.GetNamespace("mapi")

oNS.Logon(outlook_Profile, , False, True)

Dim Folder As Outlook.MAPIFolder = oNS.GetDefaultFolder(6)
Dim FolderItemsW As Outlook.Items = Folder.Items

dim mapicount as integer
mapicount = FolderItemsW.count
'this gives me 4039

Please let me know what is the other way to log on.

Thanks again
 
D

Dmitry Streblechenko

How about questions 1 through 3?
When you call RDOSession.LogonExchangeMailbox, Redemption creates a
temporary profile with an online (as opposed to cached) store. This is
similar to using Session.Login with ProfileInfo parameter used in CDO 1.21.
4a. What happens if you call RDOSession.Logon(outlook_Profile)?
4b. What happens if you run your OOM code first, then instead of calling
session.LogonExchangeMailbox call
session.MAPIOBJECT = oNS.MAPIOBJECT?
This way both Outlook and Redemption will be using the same physical MAPI
session.

I bet the existing profile (outlook_Profile) uses cached mode, while
LogonExchangeMailbox() will give you aan online store, which can be
different.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
M

mirzoni

Hi Dimirty,

Man, thanks for that!

This worked:
session.MAPIOBJECT = oNS.MAPIOBJECT
(now it totally makes sense)

Now i've got stuck on the next part!
In this app, after login, i create a new folder: root>scanned>(date an
time)
and place the redemption mailitems one by one in that folder... simpl
right?

When I used the session.LogonExchangeMailbox(MailBoxName, Server)
could execute the move however now I can not.

...
session.MAPIOBJECT = oNS.MAPIOBJECT
Dim ScanFolder As Redemption.RDOFolder

Dim DateAndTimeNOW As String
DateAndTimeNOW = Now()
ScanFolder
session.Stores.DefaultStore.IPMRootFolder.Folders("Scanned").Folders.Add(DateAndTimeNOW)

Dim FolderItemsRED As Redemption.RDOFolder
FolderItemsRED = session.GetDefaultFolder(6)

Dim MailTo As Redemption.RDOMail
For i = 1 To FolderItemsRED.Items.Count
MailTo = FolderItemsRED.Items(i)
MailTo.Move(ScanFolder)
next i
....
the app dies on: MailTo.Move(ScanFolder)

please disregard the fact that when the "i' gets t
(FolderItemsRED.Items.Count/2) that the app will break.
this is because items are getting moved to another folder so the "i
reference will go above the actual count. I have another more comple
routine that handles that issue but in this case I have shortened i
for the purpose of clarity and getting to the bottom of why does th
app break on:
MailTo.Move(ScanFolder).

please hel
 
D

Dmitry Streblechenko

What is the *exact* error?
How do you decide which items get copied where? Your code will not copy the
first half of the items, it will copy every second one.
Also note that your code will be a lot tmore efficient if you cache the
value of FolderItemsRED.Items rather than call it on each step of the loop;
you will get a brand new COM object each time.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
M

mirzoni

hi,
thanks for you help.
here is the copy of the error:

++++++++++++++++++

System.Runtime.InteropServices.COMException occurred
ErrorCode=-2147417852
Message="Error in IMsgServiceAdmin::AdminProviders: RPC_E_FAULT"
Source="Redemption.RDOReportItem"
StackTrace:
at Redemption.RDOMailClass.Move(RDOFolder DestFolder)
at EmailScanner.ScanManager.LoadRawMessageMAPI(Items
FolderItems)

++++++++++++++++++

this started when this: session.MAPIOBJECT = oNS.MAPIOBJECT
was added and this: session.LogonExchangeMailbox(MailBoxName, Server)
was taken out.


++++++++++++++++++
i looked up this error on google and found the following:
http://peach.ease.lsoft.com/scripts/wa.exe?A2=ind0511&L=mapi-l&T=0&P=18593

...
Is your code running as a separate exe rather than an Outlook
add-in/extension?
There are quite a few bugs in MAPI when it comes to marshallin
IMAPISession
across the process boundaries - you will get back the RPC_E_FAULT erro
when
you touch the profiles API (IProfAdmin etc) or call Imessage::CopyTo(
or
open the ACL table under Exchange.
Make sure that IMAPISession lives in your process address space so tha
it
won't have to be marshalled - use MAPILogonEx() to retriev
IMAPISession
instead of reading it from Namespace.MAPIOBJECT.
...
++++++++++++++
now, since i HAVE to use session.MAPIOBJECT = oNS.MAPIOBJECT (as onl
that brings me back good results) is there a way to move these message
to another folder? is there a way out?


again, thanks for you help
 
D

Dmitry Streblechenko

Nope, you need to use RDOSession.Logon/LogonExchangeMailbox instead of
setting the MAPIOBJECT property - there's a marshalling bug in MAPI, nothing
Redemption can do. AFAIK that was fixed in Outlook 2007.
As a workaround, you can create a new message in the target folder
explicitly (RDOFolder.Items.Add), then call RDOMail.CopyTo(), then
RDOMail.Delete. Just keep in mind that doing so instead of calling MoveTo()
does not preserve created and last modified dates.
Why can't you use Logon?

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top