Is it possible to rename a folder with files inside using VBA (Outlook)?

Posted on

Question :

I have a simple process where a text file arrives by email and I should save it to a certain location inside a folder whose name is a date that is inside this file.
With this in mind I have developed the code below that does the following process:

1) Through an email rule, Outlook checks if the sender of the message is selected and if so, it executes the code
2) The code saves the attachment in a folder named “temp”
3) The code reads the second line of the saved file where a date is located
4) The Code renames this folder “temp” to the date read in the file

The problem is that when the code tries to rename the folder it shows the error code code 70 (Permission denied).

Is it possible to rename a folder with files inside using VBA (Outlook)?

Code:

Public Sub SalvarAnexo(Item)

Dim Atmt As Attachment
Dim FileName As String
Dim objFSO As Object
Dim objFile As Object
Dim strData As String
Dim caminhoTemp As String
Dim caminhoFinal As String
Dim caminhoFtp As String
Dim fdr

'MsgBox "Mensagem Recebida de " & Item.Sender & "!"
'caminhoTemp = "Z:MIS.Bases.big data.PF15temp"
'caminhoFinal = "Z:MIS.Bases.big data.PF15"

Answer :

Leave a Reply

Your email address will not be published. Required fields are marked *