What are oPF and oSM? What is the value of Saved after you change HTMLBody?
--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54
This time around I
decided to make the message field read only and then provide a textbox
and button for adding notes. When you type something in the textbox
and push the button it adds the text to the message. I am actually
inserting it into the top of an HTML table using the HTMLBody
property. It works fine other than not dirtying the form so if that is
the only change you make it does not want to save it. Of course, I can
flag that it was updated and force a save in the Item_Close event if
the Item_Write event has not fired yet. That works but that also means
that if someone presses the X button the form is saved and that does
not make sense.
Here is where I update the HTMLBody field (also Mileage and Subject)
Sub AddNote(sText)
' Check
If Trim(sText) = "" Then Exit Sub
' Check if first add
If Not bAddedNote Then
bAddedNote = True
Item.Mileage = Item.Mileage + 1
Item.Subject = Now
End If
' Get existing body
sHTML = Item.HTMLBody
' Search for end of header
iPos = InStr(sHTML, "</th></tr>")
' Highlight so each users notes are grouped
sHL = ""
If Item.Mileage / 2 = Int(Item.Mileage / 2) Then sHL = ";background-
color: lightgoldenrodyellow"
' Insert new line
sHTML2 = Left(sHTML, iPos + 9)
sHTML2 = sHTML2 & "<tr><td style='width:100px" & sHL & "'>" &
FormatDateTime(Now, 2) & " " & FormatDateTime(Now, 4) & "</td>"
sHTML2 = sHTML2 & "<td style='width:125px" & sHL & "'>" &
oPF.CurrentUser & "</td>"
sHTML2 = sHTML2 & "<td style='" & sHL & "'>" & sText & "</td></tr>"
sHTML2 = sHTML2 & Mid(sHTML, iPos + 10)
' Update body
Item.HTMLBody = sHTML2
End Sub
Here is what I have so far in the Item_Write and Item_Close events:
' If readonly then do not save
If oPF.ReadOnly Then
Item_Write = False
Item.Close(1)
Exit Function
End If
' Save If New
If oPF.IsNew Then Item.Save
' Update user types
oSM.AddUserType "LP", oPF.Field("LPName")
oSM.AddUserType "LC", oPF.Field("LCName")
oSM.AddUserType "DEUW", oPF.Field("DEUWName")
oSM.AddUserType "Funder", oPF.Field("FunderName")
oSM.AddUserType "Treasury", oPF.Field("TreasuryName")
' Send emails
'If Ubound(oSM.GetEmailRecipients(oPF.Field("CurrentStatus"))) > -1
Then
'For Each sEmail In
oSM.GetEmailRecipients(oPF.Field("CurrentStatus"))
' If Trim(sEmail) <> "" Then
' oPF.SendEmail sEmail,
oSM.GetEmailText(oPF.Field("CurrentStatus")),"TEST"
' End If
'Next
'End If
' Update subject
oPF.CreatePFItem(oPF.Controls("txtLoanNumber").Value)
bWriteFired = True
End Function
Function Item_Close()
' Unlock
oPF.UnlockItem(False)
End Function- Hide quoted text -
- Show quoted text -