Exchange Public Folder as Recordset 
Author Message
 Exchange Public Folder as Recordset

I have managed to open a recordset of an Exchange Public
folder.  I have got a record count from the recordset but
when I try to add new records I get a No current record.
(Error 3021) when I try to assign a value to a field.  I
get the same error raised when I try to read records or
display the AbsolutePostion.  All the MSDN entries seem to
suggest this applies to an empty recordset but, as I said
I have got a RecordCount so I am certain it is not empty.

My code (in short) is:

Private Sub Command2_Click()
    Dim db As DAO.Database
    Dim rs As DAO.Recordset
    Dim strconnect As String
    strconnect = "Exchange 4.0;MAPILevel = Public
Folders|All Public Folders\;"
    Set db = OpenDatabase("c:\temp\", False, False,
strconnect)
    Set rs = db.OpenRecordset("GHN Contacts", dbOpenTable,
3)
    'I have tried various combinations here all with the
same result.

    Debug.Print rs.RecordCount

'these bits fall down.
    Do Until rs.EOF
        Debug.Print rs!EmailAddress
        rs.MoveNext
    Loop
    With rs
       .AddNew
       !FirstName = "test"
       !SecondName = "Entry - DAO"
       .Update
    End With

End Sub

Have I missed something?  Is there a work around? I have
looped through the properties and gathered a print out and
am familier with manipulating these.

My DAO is abit rusty as I have been using mostly ADO of
late.  I was recommended using DAO for this particular
operation and had experienced some problems with my ADO
connection string to this table.

TIA



Sun, 16 Oct 2005 20:06:16 GMT  
 Exchange Public Folder as Recordset
Stephen,

I think it's in the recordset type.  dbopentable should only be used if it's
an access table in the current db.  If it's a linked table or query and you
don't specify a type, Access will use dbOpenDynaset by default.  I'd suggest
using dbopendynaset or leave the recordset type blank so Access can choose
what to do.

Your line:
Set rs = db.OpenRecordset("GHN Contacts", dbOpenTable, 3)
should be
Set rs = db.OpenRecordset("GHN Contacts", dbOpenDynaset)

There might be a more efficient use of recordset type and options arguments
specifically for use with Exchange, but I don't know.  I do know a linked
table to exchage is updatable so you could add a linked table to the public
folder and open your recordset from that table.  Doing so will allow you to
test manually entering data into the exchange table to rule out the
potential that it's an exchange permissions issue.

HTH,
Josh


Quote:

> I have managed to open a recordset of an Exchange Public
> folder.  I have got a record count from the recordset but
> when I try to add new records I get a No current record.
> (Error 3021) when I try to assign a value to a field.  I
> get the same error raised when I try to read records or
> display the AbsolutePostion.  All the MSDN entries seem to
> suggest this applies to an empty recordset but, as I said
> I have got a RecordCount so I am certain it is not empty.

> My code (in short) is:

> Private Sub Command2_Click()
>     Dim db As DAO.Database
>     Dim rs As DAO.Recordset
>     Dim strconnect As String
>     strconnect = "Exchange 4.0;MAPILevel = Public
> Folders|All Public Folders\;"
>     Set db = OpenDatabase("c:\temp\", False, False,
> strconnect)
>     Set rs = db.OpenRecordset("GHN Contacts", dbOpenTable,
> 3)
>     'I have tried various combinations here all with the
> same result.

>     Debug.Print rs.RecordCount

> 'these bits fall down.
>     Do Until rs.EOF
>         Debug.Print rs!EmailAddress
>         rs.MoveNext
>     Loop
>     With rs
>        .AddNew
>        !FirstName = "test"
>        !SecondName = "Entry - DAO"
>        .Update
>     End With

> End Sub

> Have I missed something?  Is there a work around? I have
> looped through the properties and gathered a print out and
> am familier with manipulating these.

> My DAO is abit rusty as I have been using mostly ADO of
> late.  I was recommended using DAO for this particular
> operation and had experienced some problems with my ADO
> connection string to this table.

> TIA



Sun, 16 Oct 2005 20:53:42 GMT  
 Exchange Public Folder as Recordset
thanks, Josh

I think I might be looking in the wrong place.
As you suggested I tried to link to the folder and got the
message,
"The MAPI store 'GHN Contacts' is known but is not
available in the current profile. This can occur if you
use a profile that is designed for working offline from a
server and try to link to a folder or address book on the
server.  The wizard is unable to link to it.".

I can link the Outlook Address book that refers to this
folder however.  

I suspect that my Connection string needs to refer to the
Outlook Address Book rather than the public folder.

Intrestingly Access allowed me to connect to a Calendar in
the public folders no problem but none of the address
books in there.

will post a solution as soon as I have it nailed down.

The problems I had experienced were consitant wether
dbopendynaset or dbopentable were used so I think that is
a bit of a red herring.  None the less I ususally leave
the type blank as you suggested, was just mucking about to
try and resolve the exception.

Quote:
>-----Original Message-----
>Stephen,

>I think it's in the recordset type.  dbopentable should

only be used if it's
Quote:
>an access table in the current db.  If it's a linked

table or query and you
Quote:
>don't specify a type, Access will use dbOpenDynaset by

default.  I'd suggest
Quote:
>using dbopendynaset or leave the recordset type blank so
Access can choose
>what to do.

>Your line:
>Set rs = db.OpenRecordset("GHN Contacts", dbOpenTable, 3)
>should be
>Set rs = db.OpenRecordset("GHN Contacts", dbOpenDynaset)

>There might be a more efficient use of recordset type and
options arguments
>specifically for use with Exchange, but I don't know.  I
do know a linked
>table to exchage is updatable so you could add a linked
table to the public
>folder and open your recordset from that table.  Doing so
will allow you to
>test manually entering data into the exchange table to
rule out the
>potential that it's an exchange permissions issue.

>HTH,
>Josh





- Show quoted text -

Quote:
>> I have managed to open a recordset of an Exchange Public
>> folder.  I have got a record count from the recordset
but
>> when I try to add new records I get a No current record.
>> (Error 3021) when I try to assign a value to a field.  I
>> get the same error raised when I try to read records or
>> display the AbsolutePostion.  All the MSDN entries seem
to
>> suggest this applies to an empty recordset but, as I
said
>> I have got a RecordCount so I am certain it is not
empty.

>> My code (in short) is:

>> Private Sub Command2_Click()
>>     Dim db As DAO.Database
>>     Dim rs As DAO.Recordset
>>     Dim strconnect As String
>>     strconnect = "Exchange 4.0;MAPILevel = Public
>> Folders|All Public Folders\;"
>>     Set db = OpenDatabase("c:\temp\", False, False,
>> strconnect)
>>     Set rs = db.OpenRecordset("GHN Contacts",
dbOpenTable,
>> 3)
>>     'I have tried various combinations here all with the
>> same result.

>>     Debug.Print rs.RecordCount

>> 'these bits fall down.
>>     Do Until rs.EOF
>>         Debug.Print rs!EmailAddress
>>         rs.MoveNext
>>     Loop
>>     With rs
>>        .AddNew
>>        !FirstName = "test"
>>        !SecondName = "Entry - DAO"
>>        .Update
>>     End With

>> End Sub

>> Have I missed something?  Is there a work around? I have
>> looped through the properties and gathered a print out
and
>> am familier with manipulating these.

>> My DAO is abit rusty as I have been using mostly ADO of
>> late.  I was recommended using DAO for this particular
>> operation and had experienced some problems with my ADO
>> connection string to this table.

>> TIA

>.



Mon, 17 Oct 2005 00:07:07 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Accessing a folder in public folders using an ADO recordset

2. Link Exchange Public folder to Access 97

3. From Acces97 to an Exchange public folder

4. Create Public Folder (use in Exchange)

5. Programmatically posting to a specific Exchange public folder

6. Create Exchange Public Folders with Specified ACL Permissions with VB

7. Programmatically post a .ppt file to an Exchange public folder

8. import data from a .dbf-file into a public folder from exchange

9. Reading public folders on exchange server

10. Posting to Exchange Public Folder.

11. Create Exchange Public Folders with Specified ACL Permissions

12. public folders from exchange

 

 
Powered by phpBB® Forum Software