View Single Post
 
Old 12-18-2018, 08:39 AM
Welshgasman Welshgasman is offline Windows 10 Office 2007
Novice
 
Join Date: Jun 2011
Posts: 26
Welshgasman is on a distinguished road
Default

Hi Graham,
Thank you for the reply.

There is no Initialize_handler any more, that was removed/replaced as you said it was not necessary.?

Code is now as below and in module ThisOutlookSession, where it has always been located. The other day it stopped working almost immediately.

If I restart Outlook it then works again (for a short while at least) which was the same effect when using the Initialize_handler method.
Code:
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
    Dim strGreeting As String
    Dim iTime As Integer
    Dim strBody As String, strDivCode As String
    strGreeting = ""
    strDivCode = "<div class=WordSection1><p class=MsoNormal>"
    iTime = Val(Format(Now(), "hh"))
  
    ' Quit if not a mail item
    If TypeName(Item) <> "MailItem" Then
        Exit Sub
    End If
    
    Select Case iTime
    Case Is < 12
        strGreeting = "morning "
    Case Is < 17
        strGreeting = "afternoon "
    Case Else
        strGreeting = "evening "
    End Select

    strGreeting = "Good " & strGreeting

    
    strBody = Item.HTMLBody
    strBody = Replace(strBody, "Good day", strGreeting)
    'strBody = Replace(strBody, strDivCode, strDivCode & strGreeting)
  
    Item.HTMLBody = strBody
End Sub
Reply With Quote