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

Close document



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old November 4th 07, 10:44 AM posted to microsoft.public.outlook.program_vba
boltnia
external usenet poster
 
Posts: 3
Default Close document

In code

Sub macros(fileNameMSG, fileNameRTF)
Dim myolApp As Outlook.Application
Dim myNamespace As Outlook.NameSpace
Dim myMailItem As Outlook.MailItem

Set myolApp = Outlook.Application
Set myNamespace = myolApp.GetNamespace("MAPI")
Set myMailItem = myNamespace.OpenSharedItem(fileNameMSG)
myMailItem.SaveAs fileNameRTF, olRTF
myMailItem.Close olDiscard
Set myMailItem = myNamespace.OpenSharedItem(fileNameMSG)
myMailItem.Close olDiscard
End Sub

Before second opening file - it is generated error. When I check file - it
is locked. So, what I have to do to unlock file after closing?

Thanks
Ads
  #2  
Old November 4th 07, 01:25 PM posted to microsoft.public.outlook.program_vba
Peter Marchert
external usenet poster
 
Posts: 116
Default Close document

Hello,

set the mailitem to nothing before using it again:

Sub macros(fileNameMSG, fileNameRTF)
Dim myolApp As Outlook.Application
Dim myNamespace As Outlook.NameSpace
Dim myMailItem As Outlook.MailItem


Set myolApp = Outlook.Application
Set myNamespace = myolApp.GetNamespace("MAPI")
Set myMailItem = myNamespace.OpenSharedItem(fileNameMSG)
myMailItem.SaveAs fileNameRTF, olRTF
myMailItem.Close olDiscard
Set myMailItem = Nothing
Set myMailItem = myNamespace.OpenSharedItem(fileNameMSG)
myMailItem.Close olDiscard
End Sub

Peter


On 4 Nov., 11:44, boltnia wrote:
In code

Sub macros(fileNameMSG, fileNameRTF)
Dim myolApp As Outlook.Application
Dim myNamespace As Outlook.NameSpace
Dim myMailItem As Outlook.MailItem

Set myolApp = Outlook.Application
Set myNamespace = myolApp.GetNamespace("MAPI")
Set myMailItem = myNamespace.OpenSharedItem(fileNameMSG)
myMailItem.SaveAs fileNameRTF, olRTF
myMailItem.Close olDiscard
Set myMailItem = myNamespace.OpenSharedItem(fileNameMSG)
myMailItem.Close olDiscard
End Sub

Before second opening file - it is generated error. When I check file - it
is locked. So, what I have to do to unlock file after closing?

Thanks



  #3  
Old July 18th 08, 12:55 PM posted to microsoft.public.outlook.program_vba
Mivoat
external usenet poster
 
Posts: 3
Default Close document

I'm having the exact same problem, and for now have had to resort to using
CreateItemFromTemplate instead, which is not ideal because users think they
can change an archived message.

Here's my code:
Dim oTmp As Outlook.MailItem
TmpViewFile = TmpPath & "Email4724.msg"
Set oTmp = gnspNameSpace.OpenSharedItem(TmpViewFile)
oTmp.Display
Set oTmp = Nothing
fs.DeleteFile TmpViewFile, True '- Gives "Permission denied" error

Interestingly If I open Outlook and go to Windows Explorer and double click
on the Email4724.msg file it comes up ok for display the first time BUT if I
close it and double click again I get an error to the tune that the file is
locked in another app.

Indeed according to the Handle utility it is still locked by Outlook:

C:\Downloads\Microsoft\Handlehandle Email4724.msg

Handle v3.40
Copyright (C) 1997-2008 Mark Russinovich
Sysinternals - www.sysinternals.com

OUTLOOK.EXE pid: 10388 1F28: C:\Documents and Settings\Clive\Local
Setti
ngs\Temp\PropertyManager\Email4724.msg

So this seems like an issue with Oulook - unless I'm missing something?

TIA

Clive (London UK)


"Peter Marchert" wrote:

Hello,

set the mailitem to nothing before using it again:

Sub macros(fileNameMSG, fileNameRTF)
Dim myolApp As Outlook.Application
Dim myNamespace As Outlook.NameSpace
Dim myMailItem As Outlook.MailItem


Set myolApp = Outlook.Application
Set myNamespace = myolApp.GetNamespace("MAPI")
Set myMailItem = myNamespace.OpenSharedItem(fileNameMSG)
myMailItem.SaveAs fileNameRTF, olRTF
myMailItem.Close olDiscard
Set myMailItem = Nothing
Set myMailItem = myNamespace.OpenSharedItem(fileNameMSG)
myMailItem.Close olDiscard
End Sub

Peter


On 4 Nov., 11:44, boltnia wrote:
In code

Sub macros(fileNameMSG, fileNameRTF)
Dim myolApp As Outlook.Application
Dim myNamespace As Outlook.NameSpace
Dim myMailItem As Outlook.MailItem

Set myolApp = Outlook.Application
Set myNamespace = myolApp.GetNamespace("MAPI")
Set myMailItem = myNamespace.OpenSharedItem(fileNameMSG)
myMailItem.SaveAs fileNameRTF, olRTF
myMailItem.Close olDiscard
Set myMailItem = myNamespace.OpenSharedItem(fileNameMSG)
myMailItem.Close olDiscard
End Sub

Before second opening file - it is generated error. When I check file - it
is locked. So, what I have to do to unlock file after closing?

Thanks




  #4  
Old July 18th 08, 02:08 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Close document

Outlook caches items when they're opened and releases them from the cache a
period of time after the items are closed. That may be what you are seeing.
And there's no way to tell when an item has been unloaded from the cache
except with the Outlook 2007 object model where you can handle the
item.Unload() event, which fires after item.Close() and before the item is
unloaded from the Outlook cache.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Mivoat" wrote in message
...
I'm having the exact same problem, and for now have had to resort to using
CreateItemFromTemplate instead, which is not ideal because users think
they
can change an archived message.

Here's my code:
Dim oTmp As Outlook.MailItem
TmpViewFile = TmpPath & "Email4724.msg"
Set oTmp = gnspNameSpace.OpenSharedItem(TmpViewFile)
oTmp.Display
Set oTmp = Nothing
fs.DeleteFile TmpViewFile, True '- Gives "Permission denied" error

Interestingly If I open Outlook and go to Windows Explorer and double
click
on the Email4724.msg file it comes up ok for display the first time BUT if
I
close it and double click again I get an error to the tune that the file
is
locked in another app.

Indeed according to the Handle utility it is still locked by Outlook:

C:\Downloads\Microsoft\Handlehandle Email4724.msg

Handle v3.40
Copyright (C) 1997-2008 Mark Russinovich
Sysinternals - www.sysinternals.com

OUTLOOK.EXE pid: 10388 1F28: C:\Documents and Settings\Clive\Local
Setti
ngs\Temp\PropertyManager\Email4724.msg

So this seems like an issue with Oulook - unless I'm missing something?

TIA

Clive (London UK)


 




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
Why is the "X" used for delete so close to the "save and close"? Carol Outlook - Using Contacts 3 July 29th 07 03:31 AM
Close Message, Close Outlook cdf Outlook - General Queries 2 April 16th 07 03:42 PM
Document Imaging Bryan Outlook - Using Contacts 1 April 2nd 07 10:37 PM
Document properties steve Outlook and VBA 3 January 31st 07 03:09 PM
Preview pdf document Martino Outlook - General Queries 4 June 16th 06 04:08 AM


All times are GMT +1. The time now is 03:07 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.