Hi all,
I'm wondering if anyone could help with this... I recently found a macro online that will save my e-mails to a folder and add the date, time, sender, recipient and subject to each email as it saves it. This in itself is really helpful but would really save extra time if it was possible to do this when also saving emails when we drag and drop them... would anyone have any ideas if that's possible and how to go about it?
Thanks in advance!
The macro I have at the minute is as follows:
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.SenderName & " to " & oMail.ReceivedByName & " RE- " & " [ " & oMail.Subject & " ] "
ReplaceCharsForFileName sName, "-"
dtDate = oMail.ReceivedTime
sName = Format(dtDate, "dd.mm.yyyy", vbUseSystemDayOfWeek, _
vbUseSystem) & Format(dtDate, "-hh'nn'ss'", _
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
I'm wondering if anyone could help with this... I recently found a macro online that will save my e-mails to a folder and add the date, time, sender, recipient and subject to each email as it saves it. This in itself is really helpful but would really save extra time if it was possible to do this when also saving emails when we drag and drop them... would anyone have any ideas if that's possible and how to go about it?
Thanks in advance!
The macro I have at the minute is as follows:
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.SenderName & " to " & oMail.ReceivedByName & " RE- " & " [ " & oMail.Subject & " ] "
ReplaceCharsForFileName sName, "-"
dtDate = oMail.ReceivedTime
sName = Format(dtDate, "dd.mm.yyyy", vbUseSystemDayOfWeek, _
vbUseSystem) & Format(dtDate, "-hh'nn'ss'", _
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