M
Maike13
I wrote some Outlook VBA code so that when a message is added to the Inbox,
it creates a new folder named with the sender's name and moves the new
message into that folder. The code works fine except that, if the sender has
requested a read receipt, they get a "Your message was deleted without being
read" message, although the message wasn't deleted, just moved into a new
folder. What's the problem and how can I fix it?
Oh, one other thing, in case it's relevant. I'm using Redemption to prevent
security warnings when I access the Sender name.
Here's my code:
Public WithEvents myOlItems As Outlook.Items
Public Sub Application_Startup()
Set myOlItems = Outlook.Session.GetDefaultFolder(olFolderInbox).Items
End Sub
Private Sub myOlItems_ItemAdd(ByVal Item As Object)
Dim myFolder As Outlook.MAPIFolder
Dim myNewFolder As Outlook.MAPIFolder
Dim sItem
Set sItem = CreateObject("myOWNdllNAME.SafeMailItem") 'The Redmption DLL
- "Not my real one of course
sItem.AuthKey = "myOWNkey" 'My Redemption security key - "Also not real"
sItem.Item = Item
Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNamespace("MAPI")
Set myInbox = myNameSpace.GetDefaultFolder(olFolderInbox)
On Error GoTo existingFolder
Set myNewFolder = myInbox.Folders.Add(sItem.SenderName)
GoTo skipNameFolder
existingFolder:
Set myNewFolder = myInbox.Folders(sItem.SenderName)
skipNameFolder:
On Error GoTo 0
sItem.Move myNewFolder
End Sub
it creates a new folder named with the sender's name and moves the new
message into that folder. The code works fine except that, if the sender has
requested a read receipt, they get a "Your message was deleted without being
read" message, although the message wasn't deleted, just moved into a new
folder. What's the problem and how can I fix it?
Oh, one other thing, in case it's relevant. I'm using Redemption to prevent
security warnings when I access the Sender name.
Here's my code:
Public WithEvents myOlItems As Outlook.Items
Public Sub Application_Startup()
Set myOlItems = Outlook.Session.GetDefaultFolder(olFolderInbox).Items
End Sub
Private Sub myOlItems_ItemAdd(ByVal Item As Object)
Dim myFolder As Outlook.MAPIFolder
Dim myNewFolder As Outlook.MAPIFolder
Dim sItem
Set sItem = CreateObject("myOWNdllNAME.SafeMailItem") 'The Redmption DLL
- "Not my real one of course
sItem.AuthKey = "myOWNkey" 'My Redemption security key - "Also not real"
sItem.Item = Item
Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNamespace("MAPI")
Set myInbox = myNameSpace.GetDefaultFolder(olFolderInbox)
On Error GoTo existingFolder
Set myNewFolder = myInbox.Folders.Add(sItem.SenderName)
GoTo skipNameFolder
existingFolder:
Set myNewFolder = myInbox.Folders(sItem.SenderName)
skipNameFolder:
On Error GoTo 0
sItem.Move myNewFolder
End Sub