Private Sub Application_NewMail()
Dim oApp As Outlook.Application
Dim oFoldMail As Object
Dim oItem As Outlook.MailItem
Dim oNameSp As Outlook.NameSpace
Dim strSubject As String
'Open or attach to Outlook
Set oApp = New Outlook.Application
Set oNameSp = oApp.GetNamespace("MAPI")
'Attach to the appropriate folders
Set oFoldMail = oNameSp.GetDefaultFolder(6) '6=Inbox
Set oItem = oFoldMail.Items.Item(1)
strSubject = oItem.Subject
'This message box works, it displays the subject with the time appended
MsgBox "The name returned is:" & strSubject + " ,Time: " + CStr(Now())
'However, this does not set the subject of the message?
oItem.Subject = strSubject + " ,Time: " + CStr(Date)
Set oApp = Nothing
Set oFoldMail = Nothing
Set oItem = Nothing
Set oNameSp = Nothing
End Sub
--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Lead Author, Professional Outlook 2000 Programming, Wrox Press
Lead Author, Beginning VB 6 Application Development, Wrox Press
Attachment Options
http://www.slovaktech.com/attachmentoptions.htm
Extended Reminders
http://www.slovaktech.com/extendedreminders.htm
"MS News" <jo...@suite224.net> wrote in message
news:#dofm1ltCHA.1628@TK2MSFTNGP10...
"Ken Slovak - [MVP - Outlook]" <kens...@mvps.org> wrote in message
news:evbAzemtCHA.2600@TK2MSFTNGP11...
'this subprocedure appends the current date to every subject
(must be put in ThisOutlookSession)
Private Sub Application_NewMail()
Dim oApp As Outlook.Application
Dim oFoldMail As Object
Dim oItem As Outlook.MailItem
Dim oNameSp As Outlook.NameSpace
Dim strSubject As String
Dim strSubjectLen As Integer
'Open or attach to Outlook
Set oApp = New Outlook.Application
Set oNameSp = oApp.GetNamespace("MAPI")
'Attach to the appropriate folders
Set oFoldMail = oNameSp.GetDefaultFolder(6) '6=Inbox
'Get First Mail Message
Set oItem = oFoldMail.Items.Item(1)
'Get Subject From The Message
strSubject = oItem.Subject
'This message box works, it displays the subject with the time appended
'MsgBox "The subject returned is:" & strSubject + " " +
Right(CStr(oItem.ReceivedTime), 11)
If InStr(strSubject, "(peg)") > 0 Then
'if has time already, strips it off
strSubject = Left(strSubject, (Len(strSubject) - 18))
'Sets the subject as "(subject) + (time)"
oItem.Subject = strSubject + Mid(Right(CStr(oItem.ReceivedTime),
11), 1, 2) + "_" + Mid(Right(CStr(oItem.ReceivedTime), 11), 4, 2) + "_" +
Mid(Right(CStr(oItem.ReceivedTime), 11), 7, 2) + "_" +
Right(Right(CStr(oItem.ReceivedTime), 11), 2) + "(peg)"
Else
'Sets the subject as "(subject) + (time)"
oItem.Subject = strSubject + " " +
Mid(Right(CStr(oItem.ReceivedTime), 11), 1, 2) + "_" +
Mid(Right(CStr(oItem.ReceivedTime), 11), 4, 2) + "_" +
Mid(Right(CStr(oItem.ReceivedTime), 11), 7, 2) + "_" +
Right(Right(CStr(oItem.ReceivedTime), 11), 2) + "(peg)"
End If
'Saves and updates the Message
oItem.Save
'Finalizes Everything
Set oApp = Nothing
Set oFoldMail = Nothing
Set oItem = Nothing
Set oNameSp = Nothing
End Sub
"MS News" <jo...@suite224.net> wrote in message
news:#dofm1ltCHA.1628@TK2MSFTNGP10...