First of all, you when saving anything to the disk you need to make sure that no forbidden symbols are used in the file path. In the code sample the path is built based on the DisplayName
property value:
oAttachment.SaveAsFile sSaveFolder & oAttachment.DisplayName
Make sure the DisplayName
property value contains a valid file name.
Also you may try using the FileName property of the Attachment
class which returns a string representing the file name of the attachment.
Finally, if the code still doesn't work you may try to run it under the debugger attached and check where it fails.