R
Robert Day
Hi
I am using this RnR code (foot of message) to grab the body text of
various messages from my Inbox, write it to a text file and then move
the processed messages to a separate folder. This works fine on a
machine at home running Internet mail (albeit only on a test set of 4
messages) but is proving problematic here at work on Windows 2000 /
Outlook 2000 / Exchange Mail (don't know Exchange version). The count
of matching messages is echoed correctly but for some reason it is not
capturing the body of all of them and is not moving all of them. As an
example the code below I created 4 messages with subject "TEST" and
body text "test1", "test2", etc. Running the macro showed a count of 4
messages to process (correct) but only captured the body of 3 messages
and only moved three messages. Can anyone see any obvious mistake I am
making in the code below (watch for wrapping)?
Sub ParseFormmail()
Dim appOL As Outlook.Application
Dim nmsNameSpace As Outlook.NameSpace
Dim fldFolder As Outlook.MAPIFolder
Dim strContent As String
Dim fsoSysObj As FileSystemObject
Dim txstream As TextStream
Set fsoSysObj = New FileSystemObject
Set txstream = fsoSysObj.OpenTextFile("C:\TestMsg.txt", ForWriting,
True)
Set appOL = CreateObject("Outlook.Application")
Set nmsNameSpace = appOL.GetNamespace("MAPI")
Set fldFolder = nmsNameSpace.GetDefaultFolder(olFolderInbox)
MsgBox "You must choose the folder to move the processed items to as
the next step" & _
vbCrLf & "Make sure it is somewhere other than the Inbox",
vbOKOnly
Set destFolder = nmsNameSpace.PickFolder
Set itmItems = fldFolder.Items
Set myItems = itmItems.Restrict("[Subject] = 'TEST'")
MsgBox "There are " & myItems.Count & " consultation messages that
will be processed.", vbInformation
For Each Item In myItems
strContent = Item.Body
MsgBox (strContent)
txstream.Write (strContent)
txstream.WriteBlankLines (2)
Item.Move (destFolder)
Next
txstream.Close
End Sub
Robert
I am using this RnR code (foot of message) to grab the body text of
various messages from my Inbox, write it to a text file and then move
the processed messages to a separate folder. This works fine on a
machine at home running Internet mail (albeit only on a test set of 4
messages) but is proving problematic here at work on Windows 2000 /
Outlook 2000 / Exchange Mail (don't know Exchange version). The count
of matching messages is echoed correctly but for some reason it is not
capturing the body of all of them and is not moving all of them. As an
example the code below I created 4 messages with subject "TEST" and
body text "test1", "test2", etc. Running the macro showed a count of 4
messages to process (correct) but only captured the body of 3 messages
and only moved three messages. Can anyone see any obvious mistake I am
making in the code below (watch for wrapping)?
Sub ParseFormmail()
Dim appOL As Outlook.Application
Dim nmsNameSpace As Outlook.NameSpace
Dim fldFolder As Outlook.MAPIFolder
Dim strContent As String
Dim fsoSysObj As FileSystemObject
Dim txstream As TextStream
Set fsoSysObj = New FileSystemObject
Set txstream = fsoSysObj.OpenTextFile("C:\TestMsg.txt", ForWriting,
True)
Set appOL = CreateObject("Outlook.Application")
Set nmsNameSpace = appOL.GetNamespace("MAPI")
Set fldFolder = nmsNameSpace.GetDefaultFolder(olFolderInbox)
MsgBox "You must choose the folder to move the processed items to as
the next step" & _
vbCrLf & "Make sure it is somewhere other than the Inbox",
vbOKOnly
Set destFolder = nmsNameSpace.PickFolder
Set itmItems = fldFolder.Items
Set myItems = itmItems.Restrict("[Subject] = 'TEST'")
MsgBox "There are " & myItems.Count & " consultation messages that
will be processed.", vbInformation
For Each Item In myItems
strContent = Item.Body
MsgBox (strContent)
txstream.Write (strContent)
txstream.WriteBlankLines (2)
Item.Move (destFolder)
Next
txstream.Close
End Sub
Robert