Move email using the Close event

Status
Not open for further replies.
V

Vasil Vasilev

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
 
A

Alan Moseley

You are creating a separate process for your myApp object, which you don't

need and will cause problems. Your code doesn't actaully use the myApp

object anywhere so you don't need any of them, but if other areas of your

code do make use of them then change :-

Dim myApp As New Outlook.Application

to

Dim myApp As Outlook.Application

next change

Set myApp = CreateObject("Outlook.Application")

to

set myApp = Outlook

Lastly change

Set objNS = GetNamespace("MAPI")

to

Set objNS = Outlook.GetNamespace("MAPI")

or

Set objNS = myApp.GetNamespace("MAPI")

Does this prevent the problem?

Alan Moseley IT Consultancy

http://www.amitc.co.uk

If I have solved your problem, please click Yes below. Thanks.

"Vasil Vasilev" wrote:


> 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
 
V

Vasil Vasilev

Hi Alan,

thanks for the answer.

Unfortunatelly the problem still persists. :( No change...

"Alan Moseley" wrote:


> You are creating a separate process for your myApp object, which you don't
> need and will cause problems. Your code doesn't actaully use the myApp
> object anywhere so you don't need any of them, but if other areas of your
> code do make use of them then change :-

> Dim myApp As New Outlook.Application
> to
> Dim myApp As Outlook.Application

> next change

> Set myApp = CreateObject("Outlook.Application")
> to
> set myApp = Outlook

> Lastly change

> Set objNS = GetNamespace("MAPI")
> to
> Set objNS = Outlook.GetNamespace("MAPI")
> or
> Set objNS = myApp.GetNamespace("MAPI")

> Does this prevent the problem?

> > Alan Moseley IT Consultancy
> http://www.amitc.co.uk

> If I have solved your problem, please click Yes below. Thanks.
 
S

Sue Mosher [MVP]

Show the code you're using to invoke the Code method and give your Outlook

version and build number.

Sue Mosher

"Vasil Vasilev" <VasilVasilev> wrote in message

news:737B976C-3EBF-4834-9F75-A83045B9F27C@microsoft.com...
> 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
 
V

Vasil Vasilev

1. Outlook 2003 (11.8217.8172) SP3

2. What do you mean by "the code you're using to invoke the Code method"?

I placed the code in ThisOutlookSession and the event is automatically fired

whenever an item is closed...

Thanks

Vasil

"Sue Mosher [MVP]" wrote:


> Show the code you're using to invoke the Code method and give your Outlook
> version and build number.

> > Sue Mosher
> > >
 
A

Alan Moseley

At which line of code does the process fail? Have you tried stepping it

though?

Alan Moseley IT Consultancy

http://www.amitc.co.uk

If I have solved your problem, please click Yes below. Thanks.

"Vasil Vasilev" wrote:


> Hi Alan,

> thanks for the answer.
> Unfortunatelly the problem still persists. :( No change...

> "Alan Moseley" wrote:
>
> > You are creating a separate process for your myApp object, which you don't
> > need and will cause problems. Your code doesn't actaully use the myApp
> > object anywhere so you don't need any of them, but if other areas of your
> > code do make use of them then change :-
> > Dim myApp As New Outlook.Application
> > to
> > Dim myApp As Outlook.Application
> > next change
> > Set myApp = CreateObject("Outlook.Application")
> > to
> > set myApp = Outlook
> > Lastly change
> > Set objNS = GetNamespace("MAPI")
> > to
> > Set objNS = Outlook.GetNamespace("MAPI")
> > or
> > Set objNS = myApp.GetNamespace("MAPI")
> > Does this prevent the problem?
> > > > Alan Moseley IT Consultancy
> > http://www.amitc.co.uk
> > If I have solved your problem, please click Yes below. Thanks.

>
 
A

Alan Moseley

I think I see your problem. When you open Outlook you are setting myItem to

be the CurrentItem of the ActiveInspector (within the Application_Startup

Sub). Surely when you open outlook you won't have an ActiveInspector. You

need to set myItem when opening a MailItem surely?

Alan Moseley IT Consultancy

http://www.amitc.co.uk

If I have solved your problem, please click Yes below. Thanks.

"Vasil Vasilev" wrote:


> Hi Alan,

> thanks for the answer.
> Unfortunatelly the problem still persists. :( No change...

> "Alan Moseley" wrote:
>
> > You are creating a separate process for your myApp object, which you don't
> > need and will cause problems. Your code doesn't actaully use the myApp
> > object anywhere so you don't need any of them, but if other areas of your
> > code do make use of them then change :-
> > Dim myApp As New Outlook.Application
> > to
> > Dim myApp As Outlook.Application
> > next change
> > Set myApp = CreateObject("Outlook.Application")
> > to
> > set myApp = Outlook
> > Lastly change
> > Set objNS = GetNamespace("MAPI")
> > to
> > Set objNS = Outlook.GetNamespace("MAPI")
> > or
> > Set objNS = myApp.GetNamespace("MAPI")
> > Does this prevent the problem?
> > > > Alan Moseley IT Consultancy
> > http://www.amitc.co.uk
> > If I have solved your problem, please click Yes below. Thanks.

>
 
V

Vasil Vasilev

I tried to remove this... still no luck :(

The process fails on trying to execute

myItem.Move destFolder

"Alan Moseley" wrote:


> I think I see your problem. When you open Outlook you are setting myItem to
> be the CurrentItem of the ActiveInspector (within the Application_Startup
> Sub). Surely when you open outlook you won't have an ActiveInspector. You
> need to set myItem when opening a MailItem surely?

> > Alan Moseley IT Consultancy
> http://www.amitc.co.uk

> If I have solved your problem, please click Yes below. Thanks.

> "Vasil Vasilev" wrote:
>
> > Hi Alan,
> > thanks for the answer.
> > Unfortunatelly the problem still persists. :( No change...
> > "Alan Moseley" wrote:
> >
> > > You are creating a separate process for your myApp object, which you don't
> > > need and will cause problems. Your code doesn't actaully use the myApp
> > > object anywhere so you don't need any of them, but if other areas of your
> > > code do make use of them then change :-
> > > > Dim myApp As New Outlook.Application
> > > to
> > > Dim myApp As Outlook.Application
> > > > next change
> > > > Set myApp = CreateObject("Outlook.Application")
> > > to
> > > set myApp = Outlook
> > > > Lastly change
> > > > Set objNS = GetNamespace("MAPI")
> > > to
> > > Set objNS = Outlook.GetNamespace("MAPI")
> > > or
> > > Set objNS = myApp.GetNamespace("MAPI")
> > > > Does this prevent the problem?
> > > > > > > Alan Moseley IT Consultancy
> > > http://www.amitc.co.uk
> > > > If I have solved your problem, please click Yes below. Thanks.

> >
 
A

Alan Moseley

It will do because you are not correctly setting myItem in the first place.

Create yourself a new Class (let's say it's called Class1) and insert the

following code into it:-

Dim WithEvents myInspectors As Inspectors

Dim myDestFolder As MAPIFolder

Private Sub Class_Initialize()

Set myInspectors = Outlook.Inspectors

Set myDestFolder =

Outlook.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).Folders("Processed")

End Sub

Private Sub myInspector_NewInspector(ByVal Inspector As Inspector)

Dim myItem As Object

Set myItem = Inspector.CurrentItem

If TypeName(myItem) = "MailItem" Then

Set myMailItem = myItem

End If

Set myItem = Nothing

End Sub

Private Sub Class_Terminate()

Set myDestFolder = Nothing

Set myInspectors = Nothing

End Sub

Private Sub myMailItem_Close(Cancel As Boolean)

myMailItem.Move mtDestFolder

End Sub

Now in the ThisOutlookSession code window include the following code:-

Private Sub Application_Quit()

Set myClass = Nothing

End Sub

Private Sub Application_Startup()

Set myClass = New Class1

End Sub

This code will currently move any mailitem opened to be moved to the

processed folder, so you will need to think about including some checking

(such as the item isnt already in the processed folder).

Alan Moseley IT Consultancy

http://www.amitc.co.uk

If I have solved your problem, please click Yes below. Thanks.

"Vasil Vasilev" wrote:


> I tried to remove this... still no luck :(

> The process fails on trying to execute
> myItem.Move destFolder

> "Alan Moseley" wrote:
>
> > I think I see your problem. When you open Outlook you are setting myItem to
> > be the CurrentItem of the ActiveInspector (within the Application_Startup
> > Sub). Surely when you open outlook you won't have an ActiveInspector. You
> > need to set myItem when opening a MailItem surely?
> > > > Alan Moseley IT Consultancy
> > http://www.amitc.co.uk
> > If I have solved your problem, please click Yes below. Thanks.
> > "Vasil Vasilev" wrote:
> >
> > > Hi Alan,
> > > > thanks for the answer.
> > > Unfortunatelly the problem still persists. :( No change...
> > > > > "Alan Moseley" wrote:
> > > > > You are creating a separate process for your myApp object, which you don't
> > > > need and will cause problems. Your code doesn't actaully use the myApp
> > > > object anywhere so you don't need any of them, but if other areas of your
> > > > code do make use of them then change :-
> > > > > > Dim myApp As New Outlook.Application
> > > > to
> > > > Dim myApp As Outlook.Application
> > > > > > next change
> > > > > > Set myApp = CreateObject("Outlook.Application")
> > > > to
> > > > set myApp = Outlook
> > > > > > Lastly change
> > > > > > Set objNS = GetNamespace("MAPI")
> > > > to
> > > > Set objNS = Outlook.GetNamespace("MAPI")
> > > > or
> > > > Set objNS = myApp.GetNamespace("MAPI")
> > > > > > Does this prevent the problem?
> > > > > > > > > > Alan Moseley IT Consultancy
> > > > http://www.amitc.co.uk
> > > > > > If I have solved your problem, please click Yes below. Thanks.
> > >
 

Michael Bauer

Senior Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
Vasil,

please see also my reply in the German newsgroup.

Additionally to the already mentioned issues:

For setting an object varibale you need to use the Set statement

Set myItem = ...

Best regards

Michael Bauer

Am Wed, 22 Jul 2009 01:23:01 -0700 schrieb Vasil Vasilev:


> 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
 
A

Alan Moseley

I do apologise, I missed a line of code when cpying and pasting. The

contents of Class1 should be:-

Dim WithEvents myMailItem As MailItem

Dim WithEvents myInspectors As Inspectors

Dim myDestFolder As MAPIFolder

Private Sub Class_Initialize()

Set myInspectors = Outlook.Inspectors

Set myDestFolder =

Outlook.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).Folders("Processed")

End Sub

Private Sub myInspector_NewInspector(ByVal Inspector As Inspector)

Dim myItem As Object

Set myItem = Inspector.CurrentItem

If TypeName(myItem) = "MailItem" Then

Set myMailItem = myItem

End If

Set myItem = Nothing

End Sub

Private Sub Class_Terminate()

Set myDestFolder = Nothing

Set myInspectors = Nothing

End Sub

Private Sub myMailItem_Close(Cancel As Boolean)

myMailItem.Move

End Sub

Alan Moseley IT Consultancy

http://www.amitc.co.uk

If I have solved your problem, please click Yes below. Thanks.

"Alan Moseley" wrote:


> It will do because you are not correctly setting myItem in the first place.
> Create yourself a new Class (let's say it's called Class1) and insert the
> following code into it:-

> Dim WithEvents myInspectors As Inspectors
> Dim myDestFolder As MAPIFolder
> Private Sub Class_Initialize()
> Set myInspectors = Outlook.Inspectors
> Set myDestFolder =
> Outlook.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).Folders("Processed")
> End Sub
> Private Sub myInspector_NewInspector(ByVal Inspector As Inspector)
> Dim myItem As Object
> Set myItem = Inspector.CurrentItem
> If TypeName(myItem) = "MailItem" Then
> Set myMailItem = myItem
> End If
> Set myItem = Nothing
> End Sub
> Private Sub Class_Terminate()
> Set myDestFolder = Nothing
> Set myInspectors = Nothing
> End Sub
> Private Sub myMailItem_Close(Cancel As Boolean)
> myMailItem.Move mtDestFolder
> End Sub

> Now in the ThisOutlookSession code window include the following code:-

> Private Sub Application_Quit()
> Set myClass = Nothing
> End Sub

> Private Sub Application_Startup()
> Set myClass = New Class1
> End Sub

> This code will currently move any mailitem opened to be moved to the
> processed folder, so you will need to think about including some checking
> (such as the item isnt already in the processed folder).

> > Alan Moseley IT Consultancy
> http://www.amitc.co.uk

> If I have solved your problem, please click Yes below. Thanks.

> "Vasil Vasilev" wrote:
>
> > I tried to remove this... still no luck :(
> > The process fails on trying to execute
> > myItem.Move destFolder
> > "Alan Moseley" wrote:
> >
> > > I think I see your problem. When you open Outlook you are setting myItem to
> > > be the CurrentItem of the ActiveInspector (within the Application_Startup
> > > Sub). Surely when you open outlook you won't have an ActiveInspector. You
> > > need to set myItem when opening a MailItem surely?
> > > > > > > Alan Moseley IT Consultancy
> > > http://www.amitc.co.uk
> > > > If I have solved your problem, please click Yes below. Thanks.
> > > > > "Vasil Vasilev" wrote:
> > > > > Hi Alan,
> > > > > > thanks for the answer.
> > > > Unfortunatelly the problem still persists. :( No change...
> > > > > > > > "Alan Moseley" wrote:
> > > > > > > You are creating a separate process for your myApp object, which you don't
> > > > > need and will cause problems. Your code doesn't actaully use the myApp
> > > > > object anywhere so you don't need any of them, but if other areas of your
> > > > > code do make use of them then change :-
> > > > > > > > Dim myApp As New Outlook.Application
> > > > > to
> > > > > Dim myApp As Outlook.Application
> > > > > > > > next change
> > > > > > > > Set myApp = CreateObject("Outlook.Application")
> > > > > to
> > > > > set myApp = Outlook
> > > > > > > > Lastly change
> > > > > > > > Set objNS = GetNamespace("MAPI")
> > > > > to
> > > > > Set objNS = Outlook.GetNamespace("MAPI")
> > > > > or
> > > > > Set objNS = myApp.GetNamespace("MAPI")
> > > > > > > > Does this prevent the problem?
> > > > > > > > > > > > > Alan Moseley IT Consultancy
> > > > > http://www.amitc.co.uk
> > > > > > > > If I have solved your problem, please click Yes below. Thanks.
> > > >
 
V

Vasil Vasilev

Alan,

thanks a lot for the code, but it still doesn't work :(

Meanwhile I found this...

http://support.microsoft.com/kb/929593/en-us

Finally, I end up writing an add-in, which does what I want on button click!

Thank you all for your help

Regards,

Vasil

"Alan Moseley" wrote:


> I do apologise, I missed a line of code when cpying and pasting. The
> contents of Class1 should be:-

> Dim WithEvents myMailItem As MailItem
> Dim WithEvents myInspectors As Inspectors
> Dim myDestFolder As MAPIFolder
> Private Sub Class_Initialize()
> Set myInspectors = Outlook.Inspectors
> Set myDestFolder =
> Outlook.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).Folders("Processed")
> End Sub
> Private Sub myInspector_NewInspector(ByVal Inspector As Inspector)
> Dim myItem As Object
> Set myItem = Inspector.CurrentItem
> If TypeName(myItem) = "MailItem" Then
> Set myMailItem = myItem
> End If
> Set myItem = Nothing
> End Sub
> Private Sub Class_Terminate()
> Set myDestFolder = Nothing
> Set myInspectors = Nothing
> End Sub
> Private Sub myMailItem_Close(Cancel As Boolean)
> myMailItem.Move
> End Sub

> > Alan Moseley IT Consultancy
> http://www.amitc.co.uk

> If I have solved your problem, please click Yes below. Thanks.

> "Alan Moseley" wrote:
>
> > It will do because you are not correctly setting myItem in the first place.
> > Create yourself a new Class (let's say it's called Class1) and insert the
> > following code into it:-
> > Dim WithEvents myInspectors As Inspectors
> > Dim myDestFolder As MAPIFolder
> > Private Sub Class_Initialize()
> > Set myInspectors = Outlook.Inspectors
> > Set myDestFolder =
> > Outlook.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).Folders("Processed")
> > End Sub
> > Private Sub myInspector_NewInspector(ByVal Inspector As Inspector)
> > Dim myItem As Object
> > Set myItem = Inspector.CurrentItem
> > If TypeName(myItem) = "MailItem" Then
> > Set myMailItem = myItem
> > End If
> > Set myItem = Nothing
> > End Sub
> > Private Sub Class_Terminate()
> > Set myDestFolder = Nothing
> > Set myInspectors = Nothing
> > End Sub
> > Private Sub myMailItem_Close(Cancel As Boolean)
> > myMailItem.Move mtDestFolder
> > End Sub
> > Now in the ThisOutlookSession code window include the following code:-
> > Private Sub Application_Quit()
> > Set myClass = Nothing
> > End Sub
> > Private Sub Application_Startup()
> > Set myClass = New Class1
> > End Sub
> > This code will currently move any mailitem opened to be moved to the
> > processed folder, so you will need to think about including some checking
> > (such as the item isnt already in the processed folder).
> > > > Alan Moseley IT Consultancy
> > http://www.amitc.co.uk
> > If I have solved your problem, please click Yes below. Thanks.
> > "Vasil Vasilev" wrote:
> >
> > > I tried to remove this... still no luck :(
> > > > The process fails on trying to execute
> > > myItem.Move destFolder
> > > > > "Alan Moseley" wrote:
> > > > > I think I see your problem. When you open Outlook you are setting myItem to
> > > > be the CurrentItem of the ActiveInspector (within the Application_Startup
> > > > Sub). Surely when you open outlook you won't have an ActiveInspector. You
> > > > need to set myItem when opening a MailItem surely?
> > > > > > > > > > Alan Moseley IT Consultancy
> > > > http://www.amitc.co.uk
> > > > > > If I have solved your problem, please click Yes below. Thanks.
> > > > > > > > "Vasil Vasilev" wrote:
> > > > > > > Hi Alan,
> > > > > > > > thanks for the answer.
> > > > > Unfortunatelly the problem still persists. :( No change...
> > > > > > > > > > > "Alan Moseley" wrote:
> > > > > > > > > You are creating a separate process for your myApp object, which you don't
> > > > > > need and will cause problems. Your code doesn't actaully use the myApp
> > > > > > object anywhere so you don't need any of them, but if other areas of your
> > > > > > code do make use of them then change :-
> > > > > > > > > > Dim myApp As New Outlook.Application
> > > > > > to
> > > > > > Dim myApp As Outlook.Application
> > > > > > > > > > next change
> > > > > > > > > > Set myApp = CreateObject("Outlook.Application")
> > > > > > to
> > > > > > set myApp = Outlook
> > > > > > > > > > Lastly change
> > > > > > > > > > Set objNS = GetNamespace("MAPI")
> > > > > > to
> > > > > > Set objNS = Outlook.GetNamespace("MAPI")
> > > > > > or
> > > > > > Set objNS = myApp.GetNamespace("MAPI")
> > > > > > > > > > Does this prevent the problem?
> > > > > > > > > > > > > > > > Alan Moseley IT Consultancy
> > > > > > http://www.amitc.co.uk
> > > > > > > > > > If I have solved your problem, please click Yes below. Thanks.
> > > > >
 
Status
Not open for further replies.
Thread starter Similar threads Forum Replies Date
G Outlook 2003 I need to move email to folder based on subject, using wild card Using Outlook 0
R List folders in a combo box + select folder + move emails from inbox to that folder + reply to that email Outlook VBA and Custom Forms 1
A Move email items based on a list of email addresses Outlook VBA and Custom Forms 40
O On click,I want to change subject line of selected mail and then reply to particular email and move Using Outlook 3
L Making rule to move email to folder from one O365 domain Using Outlook 1
S Send email via SMTP - use transport rules to add to senders inbox (then rule to move to sent items Exchange Server Administration 1
acpete48317 Categorize and move Outlook Email Outlook VBA and Custom Forms 2
S Move email accounts to new laptop Using Outlook 1
Diane Poremsky Create Tasks from Email and move to different Task folders New Slipstick.com Articles 0
O VBA Move EMail Outlook VBA and Custom Forms 3
P Move email to folder Using Outlook 1
P move a specified email "From" tag items to a certain folder whenever there is "New Mail" in the inbo Outlook VBA and Custom Forms 5
G email returns after running macro to move emails Outlook VBA and Custom Forms 1
C Outlook 2013 - Email Gets Sent - But Does Not Move From Outbox to Sent Box Using Outlook 4
D Move email to same folder as the rest of the conversation Using Outlook 1
K Outlook Cached Mode - can't create rules to move email to another mailbox Using Outlook 2
D User cannot move email messages within Outlook Inbox folder and sub-folders. Using Outlook 0
S Rule to move BCC email to a folder Using Outlook 6
D Delete an email with a video attachment. I can't delete or move it. System shows "not responding" wi Using Outlook 2
E error code MAPI error 0x80040107. I'm trying to move email messages and email lists from my old MS Using Outlook 2
B Move some email to different folder in Outlook Using Outlook 1
D Extract email addresses from inbox in a batch and move them into "bcc" for a mass email campaign Using Outlook 1
B Is it possible to move email to folders while offline in Outlook 2007? Using Outlook 2
J content of__html email is not visible when they have rules to move email automatically to__a PST Using Outlook 3
T want to move email contact addresses from outlook express to Outlook Using Outlook 4
R In Office 2010, after reading and closing an email item, how do I tell Outlook to move to the previous item in the folder? Using Outlook 1
M Outlook email move to folder permissions question. Using Outlook 1
O How to set rule to move email from hotmail account into Inbox? Using Outlook 1
B Move Sent Email to archival pst folder and mark as read - HOW TO Outlook VBA and Custom Forms 2
V move read email based on date and sender Outlook VBA and Custom Forms 6
P Move emails between 2 mailboxes. Using Outlook 1
C Copy Move item won't work Outlook VBA and Custom Forms 2
N Macro to move all recipients to CC while replying Outlook VBA and Custom Forms 0
Commodore Move turns into "copy" Using Outlook 3
Jennifer Murphy Ctrl+Tab sometimes will not move through text a word at a time Using Outlook 1
V Outlook 2016 will not move emails in search results Using Outlook 4
M move to iCloud not working in outlook calendar Using Outlook 12
A Create date folder and move messages daily Outlook VBA and Custom Forms 1
Commodore Folders always closed in move/copy items dialog box Using Outlook 3
C Move Outlook 2007 to new PC with Outlook 365 Using Outlook 3
C Can't move folder, the folder is full Using Outlook 0
Nadine Rule to move attachments with specific name Outlook VBA and Custom Forms 1
T Move calendar invites to new calendar Using Outlook 5
O Rule to move (specific) messages from Sent folder to Specific folder Using Outlook 1
I Automating message move between folders Outlook VBA and Custom Forms 0
K Outlook Rules: Move a Copy Using Outlook 4
K VBA BeforeItemMove event create rule to always move to its folder. Outlook VBA and Custom Forms 4
N Move emails of same conversation to same subfolder Using Outlook 6
P when i move inbox mails to another folder in outlook the mail disappears Using Outlook 1
Peter H Williams How to Move Mail item after processing Outlook VBA and Custom Forms 5
Similar threads


















































Top