Custom Form fields being lost when reply, replyall, forward

B

Blair Nygren

Really a mutlti-stage question:

I'm working programmatically to associate customer data to a message and
then set the custom form (messageclass) to the form. Everything works fine,
expect when I open the message with the custom form, hit reply, forward or
replyall repeatly.
If I hit reply,replyall or forward the reply method (Reply object) contains
the new message with the proper message class indicated by the actions
definition in the custom form. However, if I close the new message and then
hit reply(all) or forward again, the message class of the original message
and the new message are IPM.Note.Message and not the correct messageclass of
the custom form.
Any help would be great.
 
S

Sue Mosher [MVP-Outlook]

Well something is changing the class to IPM.Note.Message. Outlook isn't
going to do that on its own. Is IPM.Note.Message by any chance a form you've
published somewhere?
I'm working programmatically to associate customer data to a message and
then set the custom form (messageclass) to the form

I am concerned about this scenario. The more usual procedure would be to
change the message class, save the item, reopen it and then add the data to
custom fields that were defined in the custom form.

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
B

Blair Nygren

Sorry for the confusion. I mistyped, it is IPM.NOTE my form in the
Organization Forms library is IPM.NOTE.CP_Message

Here's the steps.

Our add-in allows the user to associate DataBase Key Info to an e-mail
message for storage and reseearching capability. The association is
performed by a commandbutton that changes the email messageclass to
IPM.NOTE.CP_Message and creates the fields necessary for reference.
At the point of association our new messageclass takes affect and the email
has a new icon representing our form. When it is opened the new form tabs
and fields are present. Everything is fine at this point.

The actions tab on the form use IPM.NOTE.CP_Message for any reply,replyall,
forward. This ensures that the form will be used to maintain the same
association.
We check in the Reply(all) event for the proper messageclass and ensure the
proper association. I noticed, that if hitting reply everything works fine
the first time. However before closing the message, I hit reply again and
the message class is IPM.NOTE and not IPM.NOTE.CP_Message. The original
message is not modified.


Sue Mosher said:
Well something is changing the class to IPM.Note.Message. Outlook isn't
going to do that on its own. Is IPM.Note.Message by any chance a form you've
published somewhere?
I'm working programmatically to associate customer data to a message and
then set the custom form (messageclass) to the form

I am concerned about this scenario. The more usual procedure would be to
change the message class, save the item, reopen it and then add the data to
custom fields that were defined in the custom form.

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
S

Sue Mosher [MVP-Outlook]

I think this may be the problem:
changes the email messageclass to
IPM.NOTE.CP_Message and creates the fields necessary for reference.

If you add fields after you change the MessageClass to a custom form, you
one-off the item, embedding the form definition it so that it no longer uses
the published form.

Instead, the fields should already be defined in the IPM.NOTE.CP_Message
form. See http://www.outlookcode.com/d/fields.htm

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
B

Blair Nygren

Thanks Sue,

The message is not being one-off 'ed because all the fields are present in
the form. However, I've had to code around the fact that the reply may not
be the IPM.NOTE.CP_Message type even though it is set as such. Here is the
code snipet for objMailItem_Reply as coded. You see I change the Message
Class of the Reply. However if I change the code to set the field and not
add it, I get an error.

Private Sub objMailItem_Reply(ByVal Response As Object, Cancel As Boolean)
On Error GoTo Error_Handler

Dim oMail As Outlook.MailItem
Dim oUserProp As UserProperty
Dim strMessageClass As String

If TypeName(Response) = "MailItem" Then
Set oMail = Response
Call WriteLog(TRACE, "clsOutLook->objMailItem->Reply: Response Mail
Item : Subject = " & oMail.Subject & " Message Class = " & oMail.MessageClass)
Call WriteLog(TRACE, "clsOutlook>objMailitem->Reply: Original
Message Class " & objMailItem.MessageClass)
strMessageClass = objMailItem.MessageClass
If LCase(oMail.MessageClass) = "ipm.note" And
(LCase(strMessageClass) = "ipm.note.cp_message" Or LCase(strMessageClass) =
"ipm.note.cp_messageack") Then
Call WriteLog(TRACE, "objMailItem->Reply: Current Mesasge is
CP_message and New Response is IPM.Note")
5 oMail.MessageClass = "IPM.Note.CP_Message" ' Set to CP_Message
6 oMail.UserProperties.Add("IsDirty", olText) = "C"
Dim CurUser As String
CurUser = GetMailboxDisplayName
Dim objADSI As New ADSIFuncs
Set oUserProp = objMailItem.UserProperties.Find("MailNickName")
10 If (TypeName(oUserProp) <> "Nothing") Then
oMail.UserProperties.Add("MailNickName", olText) =
objMailItem.UserProperties.Item("MailNickName").Value
Set oUserProp = objMailItem.UserProperties.Find("CaseSK")
20 If (TypeName(oUserProp) <> "Nothing") Then
oMail.UserProperties.Add("CaseSK", olText) =
objMailItem.UserProperties.Item("CaseSK").Value
Set oUserProp = objMailItem.UserProperties.Find("Matter")
30 If (TypeName(oUserProp) <> "Nothing") Then
oMail.UserProperties.Add("Matter", olText) =
objMailItem.UserProperties.Item("Matter").Value
Set oUserProp = objMailItem.UserProperties.Find("Style")
40 If (TypeName(oUserProp) <> "Nothing") Then
oMail.UserProperties.Add("Style", olText) =
objMailItem.UserProperties.Item("Style").Value
Set oUserProp = objMailItem.UserProperties.Find("DatabaseName")
50 If (TypeName(oUserProp) <> "Nothing") Then
oMail.UserProperties.Add("DatabaseName", olText) =
objMailItem.UserProperties.Item("DatabaseName").Value
Set oUserProp = objMailItem.UserProperties.Find("ProfileName")
60 If (TypeName(oUserProp) <> "Nothing") Then
oMail.UserProperties.Add("ProfileName", olText) =
objMailItem.UserProperties.Item("ProfileName").Value
Set oUserProp = objMailItem.UserProperties.Find("UserSaveAttach")
70 If (TypeName(oUserProp) <> "Nothing") Then
oMail.UserProperties.Add("UserSaveAttach", olNumber) =
objMailItem.UserProperties.Item("UserSaveAttach").Value
Set oUserProp = objMailItem.UserProperties.Find("DocXML")
80 If (TypeName(oUserProp) <> "Nothing") Then
oMail.UserProperties.Add("DocXML", olText) =
objMailItem.UserProperties.Item("DocXML").Value
Set oUserProp = objMailItem.UserProperties.Find("MovedDocs")
90 If (TypeName(oUserProp) <> "Nothing") Then
oMail.UserProperties.Add("MovedDocs", olText) =
objMailItem.UserProperties.Item("MovedDocs").Value
oMail.UserProperties.Add("MessageGUID", olText) = CreateGUID
Set objADSI = Nothing
End If
If (LCase(oMail.MessageClass) = "ipm.note.cp_message" Or
LCase(oMail.MessageClass) = "ipm.note.cp_messageack") Then
oMail.UserProperties.Add("Reply", olText) = "R" ' Tell it is a
reply for Strip Associate Button to Appear objmailitem_open
End If
End If
Set oMail = Nothing
Set oUserProp = Nothing
Call WriteLog(TRACE, "clsOutLook->objMailItem->Reply Complete")
Exit Sub
Error_Handler:
Call fun_ErrorHandler(Err.Number, Err.Source, Err.Description,
"clsOutlook->objMailItem->Reply Erl" & Erl)
Exit Sub
End Sub
 
S

Sue Mosher [MVP-Outlook]

With the custom form open in design view, look at the All Fields tab, under
User-defined Fields in This Item. Are all your custom properties listed
there?

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top