I’ve got a process where I am having to extract data from saved .msg files that are saved from Office365Message emails, however neither the bot nor myself as a user can access the files when they are downloaded using the invoke code that I have in place. I get this message -
Does anyone know a workaround to get this sorted? I’ve tried running a VBScript on the .msg file and it throws the same error as the attached picture. This shouldn’t really be a problem, but it is for some reason.
I tried to use both the Save Mail Message and Save Attachments activities and I got the error “Access to Path: XXX is denied”. The user account the bot uses has full access to all folders so I am not sure why these activities do not work.
To check if write access is present on a file for the UiPath Robot user, Write a code in an “Invoke Code” activity.
Arguments :
Name : path
Direction : In
Type : String
Name : result
Direction : Out
Type : Boolean
Value : res
Code:
Dim writeAllow As Boolean = False
Dim writeDeny As Boolean = False
Dim dInfo As New DirectoryInfo(path)
Dim accessControlList As System.Security.AccessControl.DirectorySecurity = dInfo.GetAccessControl()
If(accessControlList Is Nothing) Then
result = False
Else
Dim accessRules As System.Security.AccessControl.AuthorizationRuleCollection = accessControlList.GetAccessRules(True, True,GetType(System.Security.Principal.SecurityIdentifier))
If accessControlList Is Nothing Then
result = False
Else
For Each rule As System.Security.AccessControl.FileSystemAccessRule In accessRules
If (System.Security.AccessControl.FileSystemRights.Write And rule.FileSystemRights) <> System.Security.AccessControl.FileSystemRights.Write Then Continue For
If rule.AccessControlType = System.Security.AccessControl.AccessControlType.Allow Then
writeAllow = True
ElseIf rule.AccessControlType = System.Security.AccessControl.AccessControlType.Deny Then
writeDeny = True
End If
Next
End If
End If
result = writeAllow AndAlso Not writeDeny
Try this and check if bot really have the access or not.
One more thing, Do you indicate your file with an extension, like test.msg ? If we indicate file without extension and there is a folder which name is same, this error will be thrown.
The bot manages to save attachments from other emails (excel files) in the same folder without issue, should it be able to do that if it didn’t have adequate permissions?
Yes if I save it manually I can open the .msg file and see the original email with the attachment.
I will add, I am experiencing the same issue when using Studio on my local machine and in the client virtual machine, so it’s not just a virtual machine issue I don’t think.
I experienced such problem with Outlook and MSG file in past.
Scenario is as follows:
1/ I can open the MSG file only once.
2/ After closing the MSG file window and retry openning the same MSG file I get the same message.
Checking openned files shows the MSG file is held by OUTLOOK.EXE
Only option to release it is close outlook.
Cheers
P.S. This only happens when Outlook is already running when I am openning the MSG file. Openning MSG file when Outlook is NOT running doesn’t hold the file, i.e. after closing the MSG file I can open it again.
P.P.S. So in your case the solution would be terminating Outlook process before openning MSG file.
Is it possible with save Mail Message and office365 to save as .msg. In the past and for me the present, we were only able to save to .eml and use those files without any issue. Maybe this also works for you?
This did not work unfortunately. I ended up having to get the client to change the emails to not included a forwarded outlook email. This allowed me to use the Save Attachments acitivity. Not a solution, but a workaround. Would be good if there was something that could be done about this by UiPath but I feel it is such a niche issue it probably won’t be addressed.