Question : Converting example Outlook Redemption VBS to C#

Hey everyone,
This should be really easy for 99% of you out there, I am a beginner to C# and starting to learn my way around and starting off by converting some VBS scripts i've written over the years.

I have the following code in VBS that uses Outlook Redemption that i'm trying to convert:

1:
2:
3:
4:
set Session = CreateObject("Redemption.RDOSession")
Session.LogonPstStore pstFile , 1, "PST For " & userName
set Store = Session.Stores.DefaultStore
Store.ValidateIPMTree



in C# i have the following

1:
2:
3:
4:
5:
using Redemption;
.....

Redemption.RDOSession RDSession = (Redemption.RDOSession) new Redemption.RDOSession();
RDSession.LogonPstStore(pstFile, 1, "PST For " + UsertName, 0 , 0);


The above works fine, the problem I have is the two lines

1:
2:
set Store = Session.Stores.DefaultStore
Store.ValidateIPMTree


If I try something like
1:
RDSession.Stores RDStore = new Session.Stores.DefaultStore


The type or namespace name 'RDSession' could not be found (are you missing a using directive or an assembly reference?)

For the ValidateIPMTree, i'm able to do the following, but i'm not sure if its in keeping with the context of the VBScript which uses Session to derive everything else

1:
2:
Redemption.RDOPstStore RDPstStore = (Redemption.RDOPstStore) new Redemption.RDOPstStore();
RDPstStore.ValidateIPMTree();


Looking at the Redemption documentation it shows that DefaultStore is a Property:
(again unfortunately all examples are VBS)

http://www.dimastr.com/redemption/rdo/rdostores.htm

DefaultStore  |  RDOStore, read/write. Returns/sets the default store
example:

1:
2:
3:
 set Session = CreateObject("Redemption.RDOSession")
Session.Logon
MsgBox "The name of the default store is" & vbCrLf & Session.Stores.DefaultStore.Name

 
and from Visual Studio object explorer it shows:

Redemption.RDOStore DefaultStore { set; get; }
    Member of Redemption.iRDOStores



Any help would be seriously appreciated.

Answer : Converting example Outlook Redemption VBS to C#

cast the RDOStore as RDOPstStore

1:
2:
Redemption.RDOPstStore RDStores; 
RDStores = (Redemption.RDOPstStore)RDSession.Stores.DefaultStore;
Random Solutions  
 
programming4us programming4us