Redemption - Outlook 2K3 crash

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
 
D

Dmitry Streblechenko \(MVP\)

Do you know which line of your code causes the crash?
BTW, Move is a function returning a new item, not a sub. After an item is
moved, you must immediately release all references to it:
Instead of
SafeItem.Item.Move myDestFolder
use
SafeItem.Item = Nothing
set oOutlookItem = oOutlookItem.Move(myDestFolder)

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
J

Jim Spicer

Hi Dimitry,
I don't know which line causes the crash - it works ok in the IDE. I'll try
and find out.

Thanks for the help on the move function. I'll make a build and have the
2002 user try it.

Jim
 
J

Jim Spicer

Problem 1 - Crash. I still don't know what causes it to crash, but I have a
cheesy work around. If the Inbox isn't empty (and whose is?) I set the
SafeItem.Item = oOutlookItem (the last message). And then proceed to close
and clean up. This seems to work, OL2K3 doesn't crash and exits quietly. Any
ideas?

Problem 2 - Deletes but doesn't move. My OL2002 user reports the same
behavior using the code changes you outlined below. The message is processed
and deleted but doesn't show up in the folder (which does get made). This
code works in our environment OL2K and OL2K3. Guess I need a copy of OL2002.

Jim
 
D

Dmitry Streblechenko \(MVP\)

1. Hmmm... What is your version of Redemption?
2. So if disappears from the source folder, but never makes it into the
target (myDestFolder) folder? How do you initialize myDestFolder?

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
J

Jim Spicer

1. Redemption version is 3.3.0.282
2. my code for the folder is:
'check for folder, and create if missing
Set myFolder = oNamespace.GetDefaultFolder(olFolderInbox)
Set myDestFolder = myFolder.Folders(gProduct.ProdName)
If myDestFolder Is Nothing Then
'make myDestFolder
myFolder.Folders.Add gProduct.ProdName, olFolders
Set myDestFolder = myFolder.Folders(gProduct.ProdName)
End If
SafeItem.Item = Nothing
Set oOutlookItem = oOutlookItem.Move(myDestFolder)

if folder isn't created it resumes next to create it

BTW, this reported move problem is probably a user cockpit error - I think
he is using the product wrong and has it set to delete, not move. sorry for
the confusion, it works on our systems.

Thanks for your help. If you roll Redemption will we get notified?

Jim
 
T

Thomas Wetzel

Hello Jim,

Do you have the Backup Add-in from Microsoft installed? Remove it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top