I have a simple macro that is saving email attachments. This has been working great, however an application that is accessing these files appears to have an issue with long file names (over 100 characters in length). I'm not a vba expert, but wondered if someone might know how to truncate/limit the file name length when macro runs and saves attachments. The first 30-40 characters include the subject, date, etc. so filenames are unique. I'm really trying to limit overall file name length for those few attachments with extremely long names. Any help appreciated! Thanks-
Sub saveAttachtoDisk(itm As Outlook.MailItem)
Dim objAtt As Outlook.Attachment
Dim saveFolder As String
Dim i As Long
Dim dateFormat
saveFolder = "Z:\"
For Each objAtt In itm.Attachments
i = i + 1
dateFormat = Format(Now, "YYYY-mm-dd HH_mm_ss")
objAtt.SaveAsFile saveFolder & "\" & itm.Subject & "-" & dateFormat & "-" & i & objAtt.DisplayName
Set objAtt = Nothing
Next
End Sub
Sub saveAttachtoDisk(itm As Outlook.MailItem)
Dim objAtt As Outlook.Attachment
Dim saveFolder As String
Dim i As Long
Dim dateFormat
saveFolder = "Z:\"
For Each objAtt In itm.Attachments
i = i + 1
dateFormat = Format(Now, "YYYY-mm-dd HH_mm_ss")
objAtt.SaveAsFile saveFolder & "\" & itm.Subject & "-" & dateFormat & "-" & i & objAtt.DisplayName
Set objAtt = Nothing
Next
End Sub