Im trying to autosave attachments with the subject. However, the subject is quite long and the first 33 characters are always the same, while the remaining part can differ in length. Ive been looking at some code and modified it as follows using the Len statement but i cant get it to work. Instead I get error messages that the path doesnt exist. Anyone has any ideas what im doing wrong?
Public Sub test(itm As Outlook.MailItem)
Dim objAtt As Outlook.Attachment
Dim saveFolder As String
Dim fDate As String
Dim posr As Integer
If Weekday(Date) = vbMonday Then
fDate = Format(Date - 3, "YYYY-MM-DD")
Else
fDate = Format(Date - 1, "YYYY-MM-DD")
End If
saveFolder = "C:\Tickets\" & fDate & "\"
For Each objAtt In itm.Attachments
objAtt.SaveAsFile saveFolder & "\" & Mid(itm.Subject, 33, len(itm.Subject)- 32) & ".pdf"
Set objAtt = Nothing
Next
End Sub
Public Sub test(itm As Outlook.MailItem)
Dim objAtt As Outlook.Attachment
Dim saveFolder As String
Dim fDate As String
Dim posr As Integer
If Weekday(Date) = vbMonday Then
fDate = Format(Date - 3, "YYYY-MM-DD")
Else
fDate = Format(Date - 1, "YYYY-MM-DD")
End If
saveFolder = "C:\Tickets\" & fDate & "\"
For Each objAtt In itm.Attachments
objAtt.SaveAsFile saveFolder & "\" & Mid(itm.Subject, 33, len(itm.Subject)- 32) & ".pdf"
Set objAtt = Nothing
Next
End Sub