juliocba
12-02-2014, 06:17 PM
Is it possible to write a macro to copy the date I received the message, paste this date into the subject and save the message in a specific directory as .msg (no unicode)?
skatonni
12-03-2014, 07:45 AM
Try this untested code.
Sub SaveAsSubjectRecTimeMsg()
Dim selectedEmail As MailItem
Dim emailsub As String
Set selectedEmail = ActiveExplorer.Selection.Item(1)
emailsub = GetValidName(selectedEmail.subject & selectedEmail.ReceivedTime)
With selectedEmail
.SaveAs "C:\direcotry\folder\" & emailsub & ".msg", olSaveAsType.olMSG
End With
End Sub
Function GetValidName(sSub As String) As String
Dim sTemp As String
sTemp = sSub
sTemp = Replace(sTemp, "\", "")
sTemp = Replace(sTemp, "/", "")
sTemp = Replace(sTemp, ":", "")
sTemp = Replace(sTemp, "*", "")
sTemp = Replace(sTemp, """", "")
sTemp = Replace(sTemp, "<", "")
sTemp = Replace(sTemp, ">", "")
sTemp = Replace(sTemp, "|", "")
GetValidName = sTemp
End Function
More info here http://msdn.microsoft.com/en-us/library/office/ff868727%28v=office.15%29.aspx
juliocba
12-04-2014, 11:06 AM
Thanks! It works well.
I had some problems because the "?" was missing in the function. I included it (sTemp = Replace(sTemp, "?", "") and it's ok now.
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.