0

I have a process where I collect files from a project folder for processing.

Users save their emails to this project folder from outlook.(Office Outlook365 on win10) In outlook you can grab a set of emails and throw them to a file explorer window to "save as". If any of the files already exist in the folder, windows gives the option to either

  1. "Copy & Replace"
  2. "Not Copy".

I want to copy, keep both and rename new with a (1) or (2) extension to the filename. filename.msg filename(1).msg

Anyone have a suggestion on how this can be achieved? and made easy for non-technical users?

I thought there might be a registry setting to allow for default rename of copied files or something.

Other Solutions suggested for this problem suggest saving to a temp folder and then copy from temp folder to project folder and then you get option to overwrite/rename, but it is a longwinded and potentially disastrous method that relies on you clicking multiple checkboxes every time to not overwrite your saved files.

1 Answer 1

0

According to my experience, there may be no option that could set it in Outlook directly. As a workaround, it's recommended to work with any vba scripts. Based on my tests, this script could save the message with the received time and subject locally:

Option Explicit
Public Sub SaveMessageAsMsg()
  Dim oMail As Outlook.MailItem
  Dim objItem As Object
  Dim sPath As String
  Dim dtDate As Date
  Dim sName As String
  Dim enviro As String
 
    enviro = CStr(Environ("USERPROFILE"))
   For Each objItem In ActiveExplorer.Selection
   If objItem.MessageClass = "IPM.Note" Then
    Set oMail = objItem
   
  sName = oMail.Subject
  ReplaceCharsForFileName sName, "-"
 
  dtDate = oMail.ReceivedTime
  sName = Format(dtDate, "yyyymmdd", vbUseSystemDayOfWeek, _
    vbUseSystem) & Format(dtDate, "-hhnnss", _
    vbUseSystemDayOfWeek, vbUseSystem) & "-" & sName & ".msg"
     
    sPath = enviro & "\Documents\"
  Debug.Print sPath & sName
  oMail.SaveAs sPath & sName, olMSG
  
  End If
  Next
  
End Sub
 
Private Sub ReplaceCharsForFileName(sName As String, _
  sChr As String _
)
  sName = Replace(sName, "'", sChr)
  sName = Replace(sName, "*", sChr)
  sName = Replace(sName, "/", sChr)
  sName = Replace(sName, "\", sChr)
  sName = Replace(sName, ":", sChr)
  sName = Replace(sName, "?", sChr)
  sName = Replace(sName, Chr(34), sChr)
  sName = Replace(sName, "<", sChr)
  sName = Replace(sName, ">", sChr)
  sName = Replace(sName, "|", sChr)
End Sub

Reference from this article: Save Selected Email Message as .msg File

1
  • I ended up using this code to save my files to disk. It is not really the way I wanted to go and I have to create buttons on each users computer and maintain the version each person has. I did trim the subject(sName = oMail.Subject) to (sName = Left(oMail.Subject, 100)) as some users were saving emails that have very long subjects and exceeded file length limits. I also changed (oMail.ReceivedTime) to (oMail.SentOn) as each person was receiving the same email at different times creating duplicates. I only want one copy of each email even if 5 people copy their versions to the project folder. Aug 31, 2021 at 12:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .