|
-
Apr 10th, 2006, 05:34 AM
#1
Thread Starter
New Member
Premision denied saveasfile kill...
Hi
i am trying to save an attachment for temproray use and then delete it afterwards and i keep getting premission denied error when i want to delete the attachment :/
For Each eItem In Inbox.Items
If eItem.UnRead = True Then
For Each atmt In eItem.Attachments
If Right(atmt.FileName, 3) = "xml" Then
atmtP = "C:\" & atmt.FileName
atmt.SaveAsFile atmtP
'NOW WHEN I TRY TO DO THIS FOR EXAMPLE
kill atmtP ' i get premision denied error
any help would be great thanks...
-
Apr 10th, 2006, 09:18 AM
#2
Re: Premision denied saveasfile kill...
Welcome to the Forums.
Is your "attachment" a file that is open?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Apr 10th, 2006, 09:10 PM
#3
Thread Starter
New Member
Re: Premision denied saveasfile kill...
Hi,
no the file is closed.
what i do is that i loop through the un read emails and save their attachment for temporary use, because the attachment has some xml in it so i parse it and then i need to delete the temporary file. so the file is supposed to be closed. the thing is once i use saveasfile to save a temporary attachment file i can't delete it even if i manually try to delete it from outside outlook until i exit from outlook. somehow outlook takes control over the file i think :S.
-
Apr 10th, 2006, 09:13 PM
#4
Re: Premision denied saveasfile kill...
Is the temp attachment file still have any references tied to it like a file stream or file system object?
Can you post your SaveAs code procedure?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Apr 10th, 2006, 09:39 PM
#5
Thread Starter
New Member
Re: Premision denied saveasfile kill...
yeap your right, i found out the source of the problem, when I save the attachment file
atmt.SaveAsFile atmtP
If ((xmlt.ValidateXML(atmtP, schemaP)) = True) Then '<--PROBLEM WITH THIS METHOD
....
End If
i pass the atmtP to a method which checks if the attachment is of valid xml
schema, when ever i call this method i can't do anything with the file anymore, i think it keeps it open or something, anywayz the xml thingy is
written by a friend using c# and i am just using his .tlb reference, so i have to waite for him to check if he forgot to close the file or something, thanks heaps <>_<>
-
Apr 10th, 2006, 10:56 PM
#6
Re: Premision denied saveasfile kill...
Yup, sounds like atmtP has a reference left instanciated. It may be being passed byref in the arguments which will pass the actual object instead of a copy. .NET pases objects ByRef as a default where VB6/VBA passes ByVal.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|