A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Move email using the Close event



 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old July 22nd 09, 09:23 AM posted to microsoft.public.outlook.program_vba
Vasil Vasilev
external usenet poster
 
Posts: 6
Default Move email using the Close event

Hi,

I made a custom form in Outlook 2003, which I assign to email messages in a
certain subfolder of my inbox. Using this form, additional attributes can be
assigned to the email. The user must open the mail, make the assignment, save
it, and close it.
At this point I want to move this email to another folder. I'm using the
Close event, but I can't make it work...
I always get runtime error '-1040973560' (c1f40108)

Am I missing something?

Here my code:

Code:
Public WithEvents myItem As Outlook.MailItem
Dim myApp As New Outlook.Application


Private Sub Application_Startup()
       Set myApp = CreateObject("Outlook.Application")
       Set myItem = myApp.ActiveInspector.CurrentItem
       ......
End Sub


Private Sub myItem_Close(Cancel As Boolean)

    Dim objNS As Outlook.NameSpace
    Set objNS = GetNamespace("MAPI")
    
    Dim destFolder As Object  'Outlook.MAPIFolder
    Set destFolder = 
objNS.GetDefaultFolder(olFolderInbox).Folders("Processed")
    
    
    Set myItem = Application.ActiveInspector.CurrentItem
    
    If Not (myItem.MessageClass = "IPM.Note.PDV_Nachricht_de" Or _
              myItem.MessageClass = "IPM.Note.PDVA_Nachricht_de" ) Then
       MsgBox " Nothing happens"
    Else
            myItem.Move destFolder
    End If
    
End Sub
P.S. I also tried to create a temporary mail item, make it equal to the
current mail item, move this one and delete the current... but still no luck
 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Inspecter Close Event dch3 Outlook and VBA 2 August 27th 07 11:34 AM
MailItem Close Event Robert Morley Outlook and VBA 8 April 19th 07 09:03 PM
Explorer' Close event not fired j Add-ins for Outlook 9 April 2nd 07 02:24 PM
Inspector Close Event is fired when spell checking is canceled. Arcady Outlook and VBA 6 December 28th 06 02:38 PM
Cancelling Outlook.Application.ActiveExplorer.Close event? Nathan Add-ins for Outlook 1 September 8th 06 07:14 PM


All times are GMT +1. The time now is 10:39 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.