![]() |
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. |
|
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
![]()
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
|
|||
|
|||
![]()
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
|
|||
|
|||
![]()
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
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
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 |