|
 |
asp_cdo thread: Need help using Session.GetMessage()
Message #1 by peixoto@n... on Mon, 13 May 2002 13:59:42
|
|
Hi all!!
I'm having some trouble while trying to get a message by it?s ID.
I have the IIS and the exchange server running on two different machines
(XP and windows 2000 server respectively). Could this be a problem?
What I need to do is to read a public folder named for instance ?Inbox?
and move all the messages to another public folder (named ?Archive? for
instance) while saving the messages IDs on a SQL database for later
access.
I?m using the following code:
?
If FoundInbox Then
Set objMessages = objInbox.Messages
' Loop through messages
Set objMessage = objMessages.GetFirst()
Dim objNewMsg
Do Until objMessage Is Nothing
If FoundArchive Then
Set objNewMsg = objMessage.MoveTo
(objArchive.ID,objArchive.StoreID)
objNewMsg.Update
InsertEmail oConn,objNewMsg ? save msg ID on
a SQL database.
Set objNewMsg = Nothing
Else
objMessage.Delete
End If
Set objMessage = objMessages.GetNext()
Loop
?
I've already confirmed that this code is able to actually move the
messages.
On another script I have the following code:
If oRS("MSGID")<>"" Then ?get msgID From database.
Set objMsg = objSession.GetMessage(oRS("MSGID"))
Res=objMsg.Text
If Not objMsg Is Nothing Then
Set objMsg=Nothing
End If
End If
The error I?m having is the following:
Error Type:
Collaboration Data Objects (0x4F7)
The client operation failed. [Microsoft Exchange Server Information
Store - [MAPI_E_NOT_FOUND(8004010F)]]
On the objSession.GetMessage line.
For what I read this error means that no message with that ID was found?
Any help would be appreciated?.
Thanks.
Message #2 by Sam Clohesy <sam@e...> on Mon, 13 May 2002 13:56:39 +0100
|
|
Hi all
I have sent an html email that uses frames (and references pages on a
website) a few of the recipents could not view the email- any ideas why this
mighy t be? (I am thinking either older email clients are security setting
preventing pages being 'downloaded' via email?)
Any help much appreciated
thanks
Sam
Message #3 by "Siegfried Weber" <sweber@c...> on Wed, 15 May 2002 02:18:18 +0200
|
|
I think your problem is that you are deleting/moving messages off the
collection while looping through it. A recommended way around this is to
use another approach to loop through the collection. Check
http://www.cdolive.com/cdo5.htm for some pointer.
<Siegfried />
> -----Original Message-----
> From: peixoto@n... [mailto:peixoto@n...]
> Sent: Monday, May 13, 2002 4:00 PM
> To: ASP CDO
> Subject: [asp_cdo] Need help using Session.GetMessage()
>
>
> Hi all!!
>
> I'm having some trouble while trying to get a message by it's ID.
> I have the IIS and the exchange server running on two different
machines
> (XP and windows 2000 server respectively). Could this be a problem?
>
> What I need to do is to read a public folder named for instance
'Inbox'
> and move all the messages to another public folder (named 'Archive'
for
> instance) while saving the messages IDs on a SQL database for later
> access.
>
> I'm using the following code:
>
> ...
> If FoundInbox Then
> Set objMessages =3D objInbox.Messages
>
> ' Loop through messages
> Set objMessage =3D objMessages.GetFirst()
> Dim objNewMsg
> Do Until objMessage Is Nothing
> If FoundArchive Then
> Set objNewMsg =3D objMessage.MoveTo
> (objArchive.ID,objArchive.StoreID)
> objNewMsg.Update
> InsertEmail oConn,objNewMsg ' save msg ID on
> a SQL database.
> Set objNewMsg =3D Nothing
> Else
> objMessage.Delete
> End If
> Set objMessage =3D objMessages.GetNext()
> Loop
> ...
>
> I've already confirmed that this code is able to actually move the
> messages.
>
> On another script I have the following code:
>
> If oRS("MSGID")<>"" Then 'get msgID From database.
> Set objMsg =3D objSession.GetMessage(oRS("MSGID"))
> Res=3DobjMsg.Text
> If Not objMsg Is Nothing Then
> Set objMsg=3DNothing
> End If
> End If
>
>
> The error I'm having is the following:
>
> Error Type:
> Collaboration Data Objects (0x4F7)
> The client operation failed. [Microsoft Exchange Server Information
> Store - [MAPI_E_NOT_FOUND(8004010F)]]
>
> On the objSession.GetMessage line.
> For what I read this error means that no message with that ID was
found...
>
> Any help would be appreciated....
>
> Thanks.
>
Message #4 by peixoto@n... on Wed, 15 May 2002 02:44:50
|
|
Thanks Siegfried for your suggestion!
However the problem still occurs even when I have the following code:
...
Set objMessages = objInbox.Messages
Set objMessage = objMessages.GetFirst()
If Not objMessage Is Nothing Then
MsgID=objMessage.ID
Set objMessage = Nothing
Set objNewMsg = objSession.GetMessage(MsgID)
Body=objNewMsg.Text
End If
...
The same error occurs in the objSession.GetMessage line.
Error Type:
Collaboration Data Objects (0x4F7)
The client operation failed. [Microsoft Exchange Server Information
Store - [MAPI_E_NOT_FOUND(8004010F)]]
Paulo.
> I think your problem is that you are deleting/moving messages off the
collection while looping through it. A recommended way around this is to
use another approach to loop through the collection. Check
http://www.cdolive.com/cdo5.htm for some pointer.
<Siegfried />
Message #5 by "Siegfried Weber" <sweber@c...> on Wed, 15 May 2002 04:09:41 +0200
|
|
Try to use:
Set objNewMsg =3D objSession.GetMessage(MsgID, Null)
If that doesn't work, try to supply the store ID also like this:
StoreID =3D objMessage.StoreID
Set objNewMsg =3D objSession.GetMessage(MsgID, StoreID)
<Siegfried />
> -----Original Message-----
> From: peixoto@n... [mailto:peixoto@n...]
> Sent: Wednesday, May 15, 2002 4:45 AM
> To: ASP CDO
> Subject: [asp_cdo] RE: Need help using Session.GetMessage()
>
>
> Thanks Siegfried for your suggestion!
>
> However the problem still occurs even when I have the following code:
>
> ...
> Set objMessages =3D objInbox.Messages
> Set objMessage =3D objMessages.GetFirst()
>
> If Not objMessage Is Nothing Then
> MsgID=3DobjMessage.ID
> Set objMessage =3D Nothing
>
> Set objNewMsg =3D objSession.GetMessage(MsgID)
> Body=3DobjNewMsg.Text
>
> End If
> ...
>
> The same error occurs in the objSession.GetMessage line.
>
> Error Type:
> Collaboration Data Objects (0x4F7)
> The client operation failed. [Microsoft Exchange Server Information
> Store - [MAPI_E_NOT_FOUND(8004010F)]]
>
>
> Paulo.
>
>
> > I think your problem is that you are deleting/moving messages off
the
> collection while looping through it. A recommended way around this is
to
> use another approach to loop through the collection. Check
> http://www.cdolive.com/cdo5.htm for some pointer.
>
> <Siegfried />
>
Message #6 by peixoto@n... on Wed, 15 May 2002 15:59:37
|
|
Thanks again Siegfried...
I tried your first suggestion on the test code from my last message and
it worked...
But when I tried on my actual code it still didn't work!!
After some tests I found out what was wrong with my code (at least I
think so).
The problem was on the second script (where I try to read the message by
its ID). Basically this is the code I was using:
...
Set objSession = CreateObject("MAPI.Session")
strProfileInfo = Application("SERVER_NAME") & vbLf & Application
("MAILBOX_NAME")
objSession.Logon ,,False,True,,False,strProfileInfo
If oRS("MSGID")<>"" Then
MsgID=oRS("MSGID")
Set objMsg = objSession.GetMessage(MsgID,Null)
BodyText=objMsg.Text
If Not objMsg Is Nothing Then
Set objMsg=Nothing
End If
End If
If Not objSession Is Nothing Then
objSession.Logoff
End If
...
This code failed with a MAPI_E_UNKNOWN_ENTRYID error on the GetMessage
line.
But when I added the following lines just after the objSession.Logon the
same code started to work:
'Find Public Folders
Set objInfoStores = objSession.InfoStores
For i = 1 to objInfoStores.Count
If objInfoStores.Item(i) = "Public Folders" Then
Set objInfoStore = objInfoStores.Item(i)
Exit For
End If
Next
'Find Top Folder
strPublicRootID = objInfoStore.Fields.Item
(PR_IPM_PUBLIC_FOLDERS_ENTRYID).Value
It seams strange to me that in order for the Session object to get a
message we need to grab the Public Folders Root ID (I admit my ignorance
in this matter).
Maybe you have a reasonable explanation for this. The fact is that
without this lines the code doesn't work...
Thanks again...
> Try to use:
Set objNewMsg =3D objSession.GetMessage(MsgID, Null)
If that doesn't work, try to supply the store ID also like this:
StoreID =3D objMessage.StoreID
Set objNewMsg =3D objSession.GetMessage(MsgID, StoreID)
<Siegfried />
Message #7 by "Siegfried Weber" <sweber@c...> on Thu, 16 May 2002 16:09:02 +0200
|
|
Well, I assumed you are using the code you posted in one of your
previous messages. However, I don't remember if this has been documented
but if you don't open the information store and don't supply the storied
with GetMessage CDO 1.21 will always fail.
<Siegfried />
> -----Original Message-----
> From: peixoto@n... [mailto:peixoto@n...]
> Sent: Wednesday, May 15, 2002 6:00 PM
> To: ASP CDO
> Subject: [asp_cdo] RE: Need help using Session.GetMessage()
>
>
> Thanks again Siegfried...
>
> I tried your first suggestion on the test code from my last message
and
> it worked...
>
> But when I tried on my actual code it still didn't work!!
> After some tests I found out what was wrong with my code (at least I
> think so).
> The problem was on the second script (where I try to read the message
by
> its ID). Basically this is the code I was using:
>
> ...
> Set objSession =3D CreateObject("MAPI.Session")
> strProfileInfo =3D Application("SERVER_NAME") & vbLf & Application
> ("MAILBOX_NAME")
> objSession.Logon ,,False,True,,False,strProfileInfo
>
>
> If oRS("MSGID")<>"" Then
> MsgID=3DoRS("MSGID")
> Set objMsg =3D objSession.GetMessage(MsgID,Null)
> BodyText=3DobjMsg.Text
> If Not objMsg Is Nothing Then
> Set objMsg=3DNothing
> End If
> End If
> If Not objSession Is Nothing Then
> objSession.Logoff
> End If
> ...
>
> This code failed with a MAPI_E_UNKNOWN_ENTRYID error on the GetMessage
> line.
> But when I added the following lines just after the objSession.Logon
the
> same code started to work:
>
> 'Find Public Folders
> Set objInfoStores =3D objSession.InfoStores
> For i =3D 1 to objInfoStores.Count
> If objInfoStores.Item(i) =3D "Public Folders" Then
> Set objInfoStore =3D objInfoStores.Item(i)
> Exit For
> End If
> Next
>
> 'Find Top Folder
> strPublicRootID =3D objInfoStore.Fields.Item
> (PR_IPM_PUBLIC_FOLDERS_ENTRYID).Value
>
>
> It seams strange to me that in order for the Session object to get a
> message we need to grab the Public Folders Root ID (I admit my
ignorance
> in this matter).
> Maybe you have a reasonable explanation for this. The fact is that
> without this lines the code doesn't work...
>
> Thanks again...
>
> > Try to use:
>
> Set objNewMsg =3D3D objSession.GetMessage(MsgID, Null)
>
> If that doesn't work, try to supply the store ID also like this:
>
> StoreID =3D3D objMessage.StoreID
> Set objNewMsg =3D3D objSession.GetMessage(MsgID, StoreID)
>
> <Siegfried />
|
|
 |