J
Jim Spicer
Hi,
The attached code runs pretty well. The crash happens when:
1. Outlook is not running and,
2. No item is processed.
Also, users with Outlook 2002 report it all works except the message is
deleted, not moved to folder (control logic is working.) They don't know it
crashes as stated above because their Outlook is ALWAYS running <g>. But
they will surely find out, so I have to fix it!
Code:
-----------------------------------------------------------------------
Dim SafeItem As Object
Dim objOutlook As Object
Dim oNamespace As Object
Dim Utils As Redemption.MAPIUtils
Dim oOutlookItems As Object
Dim oOutlookItem As Object
Dim other variables....
'
'initialize the runtime screen
'
'
' SET UP OUTLOOK
Set objOutlook = CreateObject("Outlook.Application")
Set oNamespace = objOutlook.GetNamespace("MAPI")
oNamespace.Logon
' SET UP REDEMPTION
Set SafeItem = CreateObject("Redemption.SafeMailItem") 'Create an
instance of RedemptionSafeMailItem
Set Utils = CreateObject("Redemption.MAPIUtils") 'Create an
instance of Redemption.MAPIUtils
' GET INBOX CONTENTS
Set oOutlookItems =
objOutlook.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).Items
' LOOK AT EACH ITEM IN THE INBOX
If oOutlookItems.Count > 0 Then 'zero items Inbox crashes Outlook if not
running?? maybe not...
For Each oOutlookItem In oOutlookItems
'decide whether to process the message
' yes we want to...
SafeItem.Item = oOutlookItem
'do a bunch of stuff, decide to save the file
attachment
SafeItem.Attachments.Item(1).SaveAsFile strPath
'logic to move or delete the message
'ok, move
SafeItem.Item.Move myDestFolder
Next
End If
ErrHandler:
If Not Err.number <> 0 Then
'clean up
Utils.Cleanup
Set Utils = Nothing
Set SafeItem = Nothing
Set oNamespace = Nothing
Set oOutlookItem = Nothing
Set oOutlookItems = Nothing
Set objOutlook = Nothing
The attached code runs pretty well. The crash happens when:
1. Outlook is not running and,
2. No item is processed.
Also, users with Outlook 2002 report it all works except the message is
deleted, not moved to folder (control logic is working.) They don't know it
crashes as stated above because their Outlook is ALWAYS running <g>. But
they will surely find out, so I have to fix it!
Code:
-----------------------------------------------------------------------
Dim SafeItem As Object
Dim objOutlook As Object
Dim oNamespace As Object
Dim Utils As Redemption.MAPIUtils
Dim oOutlookItems As Object
Dim oOutlookItem As Object
Dim other variables....
'
'initialize the runtime screen
'
'
' SET UP OUTLOOK
Set objOutlook = CreateObject("Outlook.Application")
Set oNamespace = objOutlook.GetNamespace("MAPI")
oNamespace.Logon
' SET UP REDEMPTION
Set SafeItem = CreateObject("Redemption.SafeMailItem") 'Create an
instance of RedemptionSafeMailItem
Set Utils = CreateObject("Redemption.MAPIUtils") 'Create an
instance of Redemption.MAPIUtils
' GET INBOX CONTENTS
Set oOutlookItems =
objOutlook.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).Items
' LOOK AT EACH ITEM IN THE INBOX
If oOutlookItems.Count > 0 Then 'zero items Inbox crashes Outlook if not
running?? maybe not...
For Each oOutlookItem In oOutlookItems
'decide whether to process the message
' yes we want to...
SafeItem.Item = oOutlookItem
'do a bunch of stuff, decide to save the file
attachment
SafeItem.Attachments.Item(1).SaveAsFile strPath
'logic to move or delete the message
'ok, move
SafeItem.Item.Move myDestFolder
Next
End If
ErrHandler:
If Not Err.number <> 0 Then
'clean up
Utils.Cleanup
Set Utils = Nothing
Set SafeItem = Nothing
Set oNamespace = Nothing
Set oOutlookItem = Nothing
Set oOutlookItems = Nothing
Set objOutlook = Nothing