OUTLOOK FREEWARE
Free Add-ins for Microsoft® Outlook®





Register

What Our Users Say : : :

"It's done it's job."

"Life Saver"

"Worked very well, was able to import my old mail to Outlook. Thank you very much! :-)"


Follow Us : : :



Save mail attachments with correct timestamp

Welcome, guest! You need to login in order to use this forum.
All Forums » General Questions About Outlook and Related... » Save mail attachments with correct timestamp
Pages: 1
RSS
Save mail attachments with correct timestamp, Attachment is saved with TimeStamp = NOW! Ought to be the file's LastModified timestamp!
As far as I understand, when you save a file attached to a mail, its timestamp for LastModified will be NOW, and NOT LastModified of the file that was originally attached to the mail before sending it.
Is it at all possible to retrieve this information - or is it lost when sending the mail?

If the answer is no, I would prefer to have the LastModified timestamp (when saving a mail attachment) made equal to the "Sent" timestamp of the mail. By doing this I am in some way able to keep the chronology of files.
I have made a VBA routine that can handle this. So if you are interested, you can get it! (Xmas present!)

BR Helge
Helge Larsen,

Thank you for your suggestion, but our utilities already set Date created and Date modified to original file dates.
I have tested your utility "Save Attachments". It does NOT set "Date created" and "Date modified" to original file dates, i.e. the dates that it had on the computer from which it was sent. Instead "Date created" and "Date modified" are set to the mail's "Sent"-timestam­p. That is, it functions like my VBA routine, see above.
Short answer: Yes—save the file and then set its timestamp to the email’s date.

Gmail (Drive): Use a small Apps Script: save attachments to Drive, rename with message.getDate­() (e.g., YYYY-MM-DD_HHMM­_filename.ext),­ then call Drive.Files.upd­ate({modifiedDa­te: isoDate}) to set the Drive modified time to the email’s date.

Outlook (Windows): Use Power Automate or a simple VBA rule: on new mail, save attachments to a folder and set the file’s Created/Modifie­d time to MailItem.Receiv­edTime.

macOS Mail: Use a Mail rule + AppleScript to save the file, then run SetFile or touch -t with the message’s date.

Tip: Also export the email (.eml/.msg) to keep the original metadata; include the sent/received timestamp in the attachment filename for easy sorting.
FYI:
I have made this VBA that saves all attachments (to all selected mails) to files.
WriteFiledate, CreateFiledate and AccessFiledate of these files are assigned the value of SentOn for the mail.
I am using Function AdjustFileTime from MrExcel.

Option Explicit

Sub HVL_Save_Attachments_to_Desktop()

    ' All attachments in selected mails are saved to Desktop.
    ' WriteFileDate, CreateFileDate and AccessFileDate are given the value of SentOn.
    
    Dim aMailItem As Object ' MailItem or MeetingItem or ...
    Dim Attach    As Outlook.Attachment
    Dim FS        As New Scripting.FileSystemObject
    Dim nAttach   As Integer
    Dim aDate     As Date
    Dim aFilename As String
    Dim aName     As String
    Dim anExt     As String
    Dim aPath     As String
    Dim aFullPath As String
    Dim N         As Integer
    Dim S         As String
    Dim i         As Integer
    Dim j         As Integer
    Dim k         As Integer
    Dim ret       As Long
    
    aPath = CreateObject("WSCript.Shell").SpecialFolders("Desktop")
    
    N = 0
    
    ' All selected items
    For Each aMailItem In Application.ActiveExplorer.Selection

        ' Only mails
        If aMailItem.Class = olMail Or _
           aMailItem.Class = olMeetingRequest Then
           
           ' Any attachments?
           nAttach = aMailItem.Attachments.Count
           If nAttach > 0 Then
              aDate = aMailItem.SentOn ' Mail Sent
              
              ' All attachments
              For i = 1 To nAttach
                  Set Attach = aMailItem.Attachments(i)
                  aFilename = Attach.FileName    ' .DisplayName
                  j = InStrRev(aFilename, ".")
                  aName = Left(aFilename, j - 1)
                  anExt = Right(aFilename, Len(aFilename) - j)
                  aFullPath = aPath & "\" & aName & "." & anExt
                  
                  ' Existing file?
                  k = 0
                  Do While FS.FileExists(aFullPath)
                     k = k + 1
                     aFullPath = aPath & "\" & aName & " (" & k & ")." & anExt
                  Loop
                  
                  ' Save file
                  Attach.SaveAsFile (aFullPath)
                  N = N + 1
                  
                  ' Change timestamps of file
                  ret = AdjustFileTime(aFullPath, aDate, aDate, aDate)
                    
                Next i
           
           End If
        
        End If
    
    Next aMailItem
   
    ' Message
    If N = 0 Then
       S = "No attachments found!"
    ElseIf N = 1 Then
       S = N & " attachment saved!"
    Else
       S = N & " attachments saved!"
    End If
    
    MsgBox S, vbInformation, "Mail attachments saved to Desktop"

    Set aMailItem = Nothing
    Set Attach = Nothing
    Set FS = Nothing
 
 End Sub
Pages: 1
All Forums » General Questions About Outlook and Related... » Save mail attachments with correct timestamp
Recent Blog Posts : : :

Mail Merge with Individual Attachments
This article shows how to quickly bulk-mail from Outlook to a list of recipients with different attachments.

Delete Duplicate Emails in Outlook
Microsoft Outlook is a popular organizer and a handy email application with many additional functions. But Outlook users are not immune to operational problems. One such problem is the repeated emails in the Outlook mailbox that occur due to errors or various failures.

Transfer Outlook Folders to a New Computer
Microsoft Outlook allows you to move information to another desktop by using PST data files, or by synchronizing the account with an email server. But what if you only need to move certain Outlook folders to a new computer?

Move Emails Between Folders in Outlook
You can create Outlook rules to automatically allocate emails to new folders. But to relocate messages and change the folder structure, Outlook does not offer automated tools. Let's see how you can move or copy emails manually and in an alternative manner.

18 Reasons Why Outlook Duplicates Emails, Contacts, Tasks, and Calendar Entries
Duplicate Outlook items can occur for a variety of reasons. Unnecessary copies of emails, appointments and meetings, contacts, tasks, notes, and journal entries can appear unexpectedly and interfere with your work. In this article, we have collected the most common causes of Outlook duplicates and suggested ways to deal with them.

More in blog...


Trusted Software : : :



110 Power Add-Ins for Outlook

© 2010-2024 Relief Software. All Rights Reserved. Privacy Policy  |  Terms of Use  |  EULA