Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_cdo thread: Setting read status of messages


Message #1 by "Mike Peschka" <peschkmj@a...> on Thu, 1 Nov 2001 08:15:35 -0500
I'm trying to set the read status of a message in an Exchange 2000

mailbox through ADO. A previous post on this group mentioned the

possibility of using the urn:schemas:httpmail:read property of a message

to do this. However, when I attempt to set this property, I receive the

following error...



Provider error '80040e21'



Multiple-step OLE DB operation generated errors. Check each OLE DB

status value, if available. No work was done.



/cdo/read.asp, line 34



I'm currently pulling a recordset of the inbox, looping through for the

message in question, then attempting to set the read status of the

current message. I've also tried using an UPDATE clause to set the

status but have failed there as well.



The exact code causing the error is as follows...



Set Rec  = Server.CreateObject("ADODB.Record")

Set Rs   = Server.CreateObject("ADODB.Recordset")

Dim strURLInbox



strURLMailbox ="file://./backofficestorage/StorageGroup/MBX/MailboxName/Inbox"



Rec.Open strURLMailbox

sURLInbox = Rec.Fields("urn:schemas:httpmail:inbox")

Rec.Close

Rec.Open sURLInbox, Rec.ActiveConnection



strView = "select " _

& "  ""DAV:href""" _

& ", ""urn:schemas:httpmail:read""" _

& " from scope ('shallow traversal of """ _

& strURLInbox & """') "



Rs.Open strView, Rec.ActiveConnection, adOpenDynamic, adLockOptimistic



While Not Rs.EOF

  If Rs("DAV:href") = Request.QueryString("m") Then

    ' !!!!!! The error occurs on the following line !!!!!!

    Rs.Fields.Item("urn:schemas:httpmail:read").Value = True

    Rs.Fields.Update

  End If

  Rs.MoveNext

Wend



Any help anyone may be able to provide will be much appreciated.



Thanks,



Mike Peschka

Message #2 by "Siegfried Weber" <sweber@c...> on Thu, 1 Nov 2001 18:58:43 +0100
It might be an issue how you open the record set. Make sure you run this

code locally on the Exchange 2000 Server machine and that you also

connect to a store/mailbox/folder the account used to run this code has

appropriate permissions. Also wrapping it into a transaction might be

helpful.



Try something like that (watch the line breaks):



Set objRecord =3D Server.CreateObject("ADODB.Record")

Set objRecordSet =3D Server.CreateObject("ADODB.Recordset")

Set objConnection =3D Server.CreateObject("ADODB.Connection")



strURLMailbox =3D _

         "file://./backofficestorage/domain.com/MBX/alias"



objConnection.Provider =3D "ExOLEDB.DataSource"

objConnection.Open strURLMailbox



objRecord.Open strURLMailbox, objConnection, adModeReadWrite,

adFailIfNotExists

strURLInbox =3D 

objRecord.Fields.Item("urn:schemas:httpmail:inbox").Value

objRecord.Close



objRecord.Open strURLInbox, objConnection, adModeReadWrite,

adFailIfNotExists



strSQL =3Dselect " & "  ""DAV:href""" _

& ", ""urn:schemas:httpmail:read""" _

& " from scope ('shallow traversal of """ _

& strURLInbox & """') "



objConnection.BeginTrans

objRecordSet.Open strSQL, objConnection



While Not objRecordSet.EOF

  With objRecordSet.Fields

    If .Item("DAV:href").Value =3D Request.QueryString("m") Then

      .Item("urn:schemas:httpmail:read").Value =3D True

      .Update

    End If

  End With

  objRecordSet.MoveNext

Wend



objConnection.CommitTrans

objRecord.Close

objConnection.Close



Also keep in mind that setting a message to "Read" will only change it

for the user/mailbox used to run this code. There is no globally read

flag which can be set to mark a message read for all users (if you are

trying something like that on a public folder for example).



<Siegfried />



> -----Original Message-----

> From: Mike Peschka [mailto:peschkmj@a...]

> Sent: Thursday, November 01, 2001 2:16 PM

> To: ASP CDO

> Subject: [asp_cdo] Setting read status of messages

>

> I'm trying to set the read status of a message in an Exchange 2000

> mailbox through ADO. A previous post on this group mentioned the

> possibility of using the urn:schemas:httpmail:read property of a

message

> to do this. However, when I attempt to set this property, I receive

the

> following error...

>

> Provider error '80040e21'

>

> Multiple-step OLE DB operation generated errors. Check each OLE DB

> status value, if available. No work was done.

>

> /cdo/read.asp, line 34

>

> I'm currently pulling a recordset of the inbox, looping through for

the

> message in question, then attempting to set the read status of the

> current message. I've also tried using an UPDATE clause to set the

> status but have failed there as well.

>

> The exact code causing the error is as follows...

>

> Set Rec  =3Derver.CreateObject("ADODB.Record")

> Set Rs   =3Derver.CreateObject("ADODB.Recordset")

> Dim strURLInbox

>

> strURLMailbox

> =3Dile://./backofficestorage/StorageGroup/MBX/MailboxName/Inbox"

>

> Rec.Open strURLMailbox

> sURLInbox =3Dec.Fields("urn:schemas:httpmail:inbox")

> Rec.Close

> Rec.Open sURLInbox, Rec.ActiveConnection

>

> strView =3Dselect " _

> & "  ""DAV:href""" _

> & ", ""urn:schemas:httpmail:read""" _

> & " from scope ('shallow traversal of """ _

> & strURLInbox & """') "

>

> Rs.Open strView, Rec.ActiveConnection, adOpenDynamic, adLockOptimistic

>

> While Not Rs.EOF

>   If Rs("DAV:href") =3Dequest.QueryString("m") Then

>     ' !!!!!! The error occurs on the following line !!!!!!

>     Rs.Fields.Item("urn:schemas:httpmail:read").Value =3Drue

>     Rs.Fields.Update

>   End If

>   Rs.MoveNext

> Wend

>

> Any help anyone may be able to provide will be much appreciated.

>

> Thanks,

>

> Mike Peschka

>

>




$subst('Email.Unsub')




  Return to Index