Good afternoon expert,
Code copied below works. Was able to hack the date format
so instead of mm-dd-yyyy the dat format is yyyy-mm-dd
which does a better job of listing the attchmetns in chronological order.
But I would like to have the date and time at the beginning of the
file name instaed of at the end. I have played with the code for about
an hour and I am starting to get a little crazy.
Can you tell me how to make the file name of the attachment be
yyyy-mm-dd-hhmm_filename.xxx?
Thanks.
Allen in Dallas
++++++++++++beginning of code+++++++++++++++
Sub SaveToFolder(MyMail As MailItem)
Dim strID As String
Dim objNS As Outlook.NameSpace
Dim objMail As Outlook.MailItem
Dim objAtt As Outlook.Attachment
Dim c As Integer
Dim save_name As String
'Place path to sav to on next line. Note that you must include the
'final backslash
Const save_path As String = "F:\Library\Contingent_Workforce_Consolidation\email_attach\"
strID = MyMail.EntryID
Set objNS = Application.GetNamespace("MAPI")
Set objMail = objNS.GetItemFromID(strID)
If objMail.Attachments.Count > 0 Then
For c = 1 To objMail.Attachments.Count
Set objAtt = objMail.Attachments(c)
save_name = Left(objAtt.FileName, Len(objAtt.FileName) - 5)
save_name = save_name & Format(objMail.ReceivedTime, "_yyyy-mm-dd-hhmm")
save_name = save_name & Right(objAtt.FileName, 5)
objAtt.SaveAsFile save_path & save_name
Next
End If
Set objAtt = Nothing
Set objMail = Nothing
Set objNS = Nothing
End Sub