View Single Post
  #9  
Old August 10th 09, 09:18 AM posted to microsoft.public.outlook.program_vba
Glen.Cooper[_5_]
external usenet poster
 
Posts: 1
Default Date Stamp in SUBJECT BOX of Outgoing/Incoming Mail


Hi Guys, thanks for all your help so far :-)

Here below is the script which works well enough:

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As
Boolean)
If TypeName(Item) = "MailItem" Then
Dim strSubject As String
strSubject = Item.Subject
Item.Subject = Item.SenderName & " " & Date & " " & Item.Subject
End If
End Sub
Private Sub Application_NewMailEx(ByVal EntryIDCollection As String)
Dim myNameSpace As NameSpace
Dim myInbox As MAPIFolder
Dim myItem As Object
Dim strSubject As String
Set myNameSpace = Application.GetNamespace("MAPI")
Set myInbox = myNameSpace.GetDefaultFolder(olFolderInbox)
For i = 1 To myInbox.Items.Count
Set myItem = myInbox.Items.Item(i)
If myItem.EntryID = EntryIDCollection Then Exit For
Next
strSubject = myItem.Subject
myItem.Subject = myItem.SenderName & " " & Date & " " & myItem.Subject
myItem.Save
End Sub

Exceptions are that the macro does not seem to work unless the mail has
been recieved while you are online and running OUTLOOK at the same time.
Perhaps this macro has to be run from a constanlty working server to
make sure that ALL emails are date stamped.

For all those email that arrive out of hours or when you are not at the
machine, use:

Sub Date_Stamp_Subject()
Dim myItem As MailItem
Dim strSubject As String
Set myItem = GetCurrentItem()
myItem.Subject = myItem.SenderName & " " & myItem.CreationTime & " " &
myItem.Subject
myItem.Save
End Sub
Function GetCurrentItem() As Object
Dim objApp As Outlook.Application
Set objApp = Application
On Error Resume Next
Select Case TypeName(objApp.ActiveWindow)
Case "Explorer"
Set GetCurrentItem = objApp.ActiveExplorer.Selection.Item(1)
Case "Inspector"
Set GetCurrentItem = objApp.ActiveInspector.CurrentItem
End Select
Set objApp = Nothing
End Function

This works well, BUT it date stamps the mail with the information in
the following format - *SENDERNAME YYYYMMDD HHMMSS*. I definitelty do
not need this amount of information!

Does anyone know how I can reduce the stamp to this alone?

SENDERNAME YYMMDD

Any help would be very much appreciated :-)

Thanks again.

Glen


--
Glen.Cooper
------------------------------------------------------------------------
Glen.Cooper's Profile: http://www.thecodecage.com/forumz/member.php?userid=613
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=121980

Ads