Jeremy Ollenbuttel
New Member
- Outlook version
- Outlook 2016 32 bit
- Email Account
- Exchange Server 2010
Good afternoon,
I have the following code running in Outlook 2016 along with a rule to print the attachments of specific emails as they arrive in the inbox;
This works fine if emails drop in one at a time, if I get multiple emails from the same sender I get the error 75
which is file or path error, I'm guessing that this is due to the temp save and print of the attachment.
Is ther a way of dealing with each email in turn to ensure the path is free before starting on the next?
Any help appreciated.
Kind regards
Jeremy
I have the following code running in Outlook 2016 along with a rule to print the attachments of specific emails as they arrive in the inbox;
Code:
Sub LSPrint(Item As Outlook.MailItem)
On Error GoTo OError
'detect Temp
Dim oFS As FileSystemObject
Dim sTempFolder As String
Set oFS = New FileSystemObject
'Temporary Folder Path
sTempFolder = oFS.GetSpecialFolder(TemporaryFolder)
'creates a special temp folder
cTmpFld = sTempFolder & "\OETMP" & Format(Now, "yyyymmddhhmmss")
MkDir (cTmpFld)
'save & print
Dim oAtt As Attachment
For Each oAtt In Item.Attachments
FileName = oAtt.FileName
FullFile = cTmpFld & "\" & FileName
'save attachment
oAtt.SaveAsFile (FullFile)
'prints attachment
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.NameSpace(0)
Set objFolderItem = objFolder.ParseName(FullFile)
objFolderItem.InvokeVerbEx ("print")
Next oAtt
'Cleanup
If Not oFS Is Nothing Then Set oFS = Nothing
If Not objFolder Is Nothing Then Set objFolder = Nothing
If Not objFolderItem Is Nothing Then Set objFolderItem = Nothing
If Not objShell Is Nothing Then Set objShell = Nothing
OError:
If Err <> 0 Then
MsgBox Err.Number & " - " & Err.Description
Err.Clear
End If
Exit Sub
End Sub
This works fine if emails drop in one at a time, if I get multiple emails from the same sender I get the error 75
which is file or path error, I'm guessing that this is due to the temp save and print of the attachment.
Is ther a way of dealing with each email in turn to ensure the path is free before starting on the next?
Any help appreciated.
Kind regards
Jeremy