Make move mean copy..

  • Thread starter Thread starter Slick_lar
  • Start date Start date
S

Slick_lar

My corporation uses Blackberry devices. Moving somethign from my inbox
to a PST folder does not reconcile on teh Blackberry. The reason is
that the Blackberry server does not know where the mail went, so it
leaves it on the device inbox.

I want to take a drag and drop move to a PST and change it into:

1. Copy not move.
2. Mark as read
3. Delete through trash can
4. Permanently delete.

Any ideas or code I can start with?

Thanks
 
Sorry if I wasn't clear. I want it out of my inbox on both the
Blackberry and on my desktop. If I move it to the PST, it stays on the
BB, Blackberry. If I copy it then delete it from my inbox so that it
goes through my exchange deleted items, the BB knows where it went and
it will remove it from my BB Inbox.

Does that help? Here is a link to a forum with someone having the same
issue I am having. I am trying to get around it with an Outlook macro
of some type.

http://blackberryforums.pinstack.com/346-reconciliation.html

Thanks
 
Ah, I see. Try this code, which you run after selecting the item in your
Inbox:

Sub CopyMessageAndDeleteOriginal()

Dim objOrig As Outlook.MailItem, objCopy As Outlook.MailItem
Dim objDestinationFolder As Outlook.MAPIFolder

If Application.ActiveExplorer.Selection.count = 0 Or
Application.ActiveExplorer.Selection.count > 1 Then Exit Sub

'This will prompt you to choose a folder where you want to copy the
message to
Set objDestinationFolder = Application.GetNamespace("MAPI").PickFolder

If objDestinationFolder Is Nothing Then Exit Sub

Set objOrig = Application.ActiveExplorer.Selection.Item(1)
Set objCopy = objOrig.Copy
objCopy.Move objDestinationFolder
objOrig.Delete

Set objOrig = Nothing
Set objCopy = Nothing
Set objDestinationFolder = Nothing
End Sub
 
Great, thanks for the help. I would like some more functionality.

Is it possible to capture and perform this script on a drag and drop to
a PST? The folder name coming from the drag and drop action?

Lastly, can the email be permanently deleted from the trash can after?
It has to delete through the trash can, but can be obliterated once int
eh trash can.

Thanks again for the help.

ls
 
It may be possible, but tricky, to trap the Explorer.BeforeItemCopy event.
However, if you tried to delete the original message during that event (which
isn't passed as a parameter, so you'd have to use
ActiveExplorer.Selection(1).CurrentItem), the copy action may not be done in
time. So I'd say no, unless you want to use a Timer class of some sort to
wait and then retrieve the selection and delete it.

In order to permanently delete a message, you'd need to use CDO (see sample
below) or find the message you just deleted in the Deleted Items folder and
delete it again.

Sub PermanentlyDeleteSelectedMesssage()
On Error Resume Next

Dim objSession As MAPI.Session
Dim objMessage As MAPI.Message
Dim objItem As Object

If Application.ActiveExplorer.Selection.count <> 1 Then GoTo Leave:
Set objItem = Application.ActiveExplorer.Selection.Item(1)
If objItem Is Nothing Then GoTo Leave:

Set objSession = New MAPI.Session
objSession.Logon , , , False
If objSession Is Nothing Then
'Error!
GoTo Leave:
End If

Set objMessage = objSession.GetMessage(objItem.EntryID,
Application.ActiveExplorer.CurrentFolder.StoreID)
Set objMessage = Nothing

Leave:
If Not objSession Is Nothing Then objSession.Logoff
Set objSession = Nothing
Set objItem = Nothing
End Sub
 
OK, I tried to trap the ItemCopy event, but nothing. Any example code?

What about trapping the folder ItemAdd event?

Thanks
 
Yeah, ItemAdd should do it!

Here's sample code from the Outlook VBA Help file (keep it handy, it's
essential):

Public WithEvents myOlExp As Outlook.Explorer

Sub Initalize_Handler()
Set myOlExp = Application.ActiveExplorer
End Sub

Private Sub myOlExp_BeforeItemCopy(Cancel As Boolean)
'Prompts the user before copying an item

Dim lngAns As Long 'user answer
'Display question to user
lngAns = MsgBox("Are you sure you want to copy the item?", vbYesNo)
If lngAns = vbYes Then
Cancel = False
Else
'Set Cancel argument based on answer
Cancel = True
End If

End Sub
 
Back
Top