H
hlock
I have vba in Outlook 2007 that saves each attachment on an email and imports
it to our document repository system. However, I need to remove spaces in
the file name because if the file path string with embedded spaces is passed
to the import program, it thinks each space delimits a new file name. I need
to get the 8.3 format of the file path string. Here is what I have currently:
For Each objMsg In objSelection
' This code only strips attachments from mail items.
If objMsg.Class = olMail Then
' Get the Attachments collection of the item.
Set objAttachments = objMsg.Attachments
lngCount = objAttachments.Count
If lngCount > 0 Then
' We need to use a count down loop for
' removing items from a collection. Otherwise,
' the loop counter gets confused and only every
' other item is removed.
For i = lngCount To 1 Step -1
' Save attachment before deleting from item.
' Get the file name.
strfile = objAttachments.Item(i).FileName
' Combine with the path to the Temp folder.
strfile = strFolder & strfile
' Save the attachment as a file.
objAttachments.Item(i).SaveAsFile strfile
' Delete the attachment.
'objAttachments.Item(i).Delete
ExecCmd "ttimport.exe " & app & " " & strfile
Next i
End If
objMsg.Save
End If
Next
I know that I need to put something in here to shorten the file name, but
I'm not sure where and how. Any help is appreciated. Thanks!
it to our document repository system. However, I need to remove spaces in
the file name because if the file path string with embedded spaces is passed
to the import program, it thinks each space delimits a new file name. I need
to get the 8.3 format of the file path string. Here is what I have currently:
For Each objMsg In objSelection
' This code only strips attachments from mail items.
If objMsg.Class = olMail Then
' Get the Attachments collection of the item.
Set objAttachments = objMsg.Attachments
lngCount = objAttachments.Count
If lngCount > 0 Then
' We need to use a count down loop for
' removing items from a collection. Otherwise,
' the loop counter gets confused and only every
' other item is removed.
For i = lngCount To 1 Step -1
' Save attachment before deleting from item.
' Get the file name.
strfile = objAttachments.Item(i).FileName
' Combine with the path to the Temp folder.
strfile = strFolder & strfile
' Save the attachment as a file.
objAttachments.Item(i).SaveAsFile strfile
' Delete the attachment.
'objAttachments.Item(i).Delete
ExecCmd "ttimport.exe " & app & " " & strfile
Next i
End If
objMsg.Save
End If
Next
I know that I need to put something in here to shorten the file name, but
I'm not sure where and how. Any help is appreciated. Thanks!