Re: 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 <bolt...@xxxxxxxxxxxxxxxxxxxxxxxxx> 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


.



Relevant Pages

  • Re: find sender info
    ... Dim myolApp As Outlook.Application ... Dim myNamespace As Outlook.NameSpace ... Dim myRecipient As Outlook.Recipient ...
    (microsoft.public.outlook.program_vba)
  • Re: Loop through all folders in a mailbox
    ... Dim myOlApp As Application ... Dim myNameSpace As NameSpace ... Dim myFolder As MAPIFolder ...
    (microsoft.public.outlook.program_vba)
  • Promt Window
    ... Dim myolApp As Outlook.Application ... Dim myNamespace As Outlook.NameSpace ... Dim myMailItem As Outlook.MailItem ...
    (microsoft.public.outlook.program_vba)
  • RE: Confirmation message before sending e-mail
    ... Dim myolApp As Outlook.Application ... Dim myNamespace As Outlook.NameSpace ... Dim SendingItem As Outlook.MailItem ...
    (microsoft.public.outlook.program_vba)