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.
Top