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

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

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

> >
 
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.
> > >
 
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
 
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.
> > > >
 
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.
Similar threads
Thread starter Title Forum Replies Date
G Outlook 2003 I need to move email to folder based on subject, using wild card Using Outlook 0
A Search folder and move the email Outlook VBA and Custom Forms 0
B Outlook 2019 Automatically move email after assigning category Using Outlook 4
J Quick steps delete original email and move reply/sent email to folder Using Outlook 2
F VBA to move email from Non Default folder to Sub folders as per details given in excel file Outlook VBA and Custom Forms 11
S Macro to move “Re:” & “FWD:” email recieved the shared inbox to a subfolder in outlook Outlook VBA and Custom Forms 0
D Move Email with Attachment to Folder Outlook VBA and Custom Forms 3
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 Using Outlook 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
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
H Move Selected emails to Local Drive Outlook VBA and Custom Forms 0
A Outlook 365 (OutLook For Mac)Move "On My Computer" Folder Items From Old To New Mac Computer Using Outlook 3
HarvMan Outlook 365 - Rule to Move an Incoming Message to Another Folder Using Outlook 4
humility36 Cannot move emails to archive - 440 error Outlook VBA and Custom Forms 1
C Trying to move messages between imap accounts/folders Using Outlook 5
M Move command Outlook VBA and Custom Forms 11
C Code to move mail with certain attachment name? Does Not work Outlook VBA and Custom Forms 3
B Move emails from one account to another Outlook VBA and Custom Forms 2
N How to add or delete items to Move dropdown Menu Using Outlook 0
Commodore Unable to move message Using Outlook 3
N Line to move origEmail to subfolder within a reply macro Outlook VBA and Custom Forms 0
C Move or copy from field to field Outlook VBA and Custom Forms 0
T Outlook 365 Move newly created tasks automatically on save. Outlook VBA and Custom Forms 1
NVDon Create new Move To Folder list Outlook VBA and Custom Forms 0
P Print attachments automatically and move the mail to an existing folder called "Ted" Outlook VBA and Custom Forms 4
T Macro to move reply and original message to folder Outlook VBA and Custom Forms 6
F Excel VBA to move mails for outlook 365 on secondary mail account Outlook VBA and Custom Forms 1
J Dopey move - deleted profile Using Outlook 1
GregS Outlook 2016 Move Outlook to new computer? Using Outlook 4
Witzker Macro to move @domain.xx of a Spammail to Blacklist in Outlook 2019 Outlook VBA and Custom Forms 7
G Move tasks up/down todo list by VBA Outlook VBA and Custom Forms 1
S Outlook Macro to move reply mail based on the key word in the subjectline Outlook VBA and Custom Forms 0
Eike Move mails via macro triggered by the click of a button? Outlook VBA and Custom Forms 0
G Cannot Move Autocomplete File to New Computer Using Outlook 15

Similar threads

Back
Top