Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Outlook VBA code generating Not Read receipt 1

Status
Not open for further replies.

maike13

Technical User
Oct 14, 2004
2
US
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 OK 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

 
Well I still don't know why it does this but I did find a work around. I added the following code after:
sItem.Item = Item

If sItem.Item.UnRead = True then 'If mail message is unread
sItem.Item.UnRead = False 'Mark it as read.
'This causes a correct
'"Your message was read"
'receipt to be sent
sItem.Item.UnRead = True 'Marks message as unread again
End If
 
Hi Maike13,
Your post is great!
I was wondering whether it was possible to use your code, but without Redemption?
Please let me have your comments and thank you.
Romnew
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top