Autosave attachments error using Len

Status
Not open for further replies.

scooby99

New Member
Outlook version
Outlook 2010 64 bit
Email Account
Exchange Server 2007
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
 

scooby99

New Member
Outlook version
Outlook 2010 64 bit
Email Account
Exchange Server 2007
It seems that the problem lies with the fact that theres a "/" in the subject.
If I remove it from the subject, the code works fine. Does anyone know how I can modify the code to handle the issue with "/"?
 

scooby99

New Member
Outlook version
Outlook 2010 64 bit
Email Account
Exchange Server 2007
I solved it myself by adding a replace argument into the code :)
 
Status
Not open for further replies.
Top