Hi everyone,
I have some code that allows me to amend Good day, to whatever it should be, depending on the time of day.
I now have the need to add a BCC as I use 3 different computers, and whilst the IMAP syncs all incoming mail, it does not for outgoing mail.
This is the code I am trying to use, however the SenderEmailAddress is empty, so it fails all the time.
How can I implement this extra option please.
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
' Now add a BCC if JAG email address
If item.SenderEmailAddress = "xxxx@yyyyy.co.uk" Then
item.BCC = item.BCC & ";ttttttttt@gmail.com"
End If
If Left(item.BCC, 1) = ";" Then item.BCC = Mid(item.BCC, 2)
strBody = item.HTMLBody
strBody = Replace(strBody, "Good day", strGreeting)
'strBody = Replace(strBody, strDivCode, strDivCode & strGreeting)
item.HTMLBody = strBody
End Sub