S
shubhangi
hello!
I need to monitor Inbox Items,if the item contains Xheader or not.I have one
command button
"save" on Read Msg Window form region.If the msg contains Xheader(say
x-matter) then
modify it with whatever value supplied by user,if the msg doesn't contain
Xheader then add xheader to that msg(x-matter) with value supplied by
user.I've Below code,it works if the
msg already has Xheader(x-matter) but not if the msg doesn't have
xheader(x-matter)
Dim PR_TRANSPORT_MESSAGE_HEADERS As String = &H7D001E
Dim strOldAllXheaderValue, strNewAllXheaderValue,
strOldXheaderValue, strNewXheaderValue As String
Dim iStartLoc, iEndLoc As Integer
sItem = CreateObject("Redemption.SafeMailItem")
sItem.Item = MailItem
strOldAllXheaderValue =
sItem.Fields(PR_TRANSPORT_MESSAGE_HEADERS)
strNewAllXheaderValue = strOldAllXheaderValue
iStartLoc = InStr(strOldAllXheaderValue, "x-matter",
CompareMethod.Text)
If iStartLoc > 0 Then strOldXheaderValue =
Mid(strOldAllXheaderValue, iStartLoc)
iEndLoc = InStr(strOldXheaderValue, gblSeparator)
'gblSeparator is "<;;;>"
AddTrace("EndLoc:" & iEndLoc)
If iStartLoc > 0 And iEndLoc > 0 Then
strOldXheaderValue = Left(strOldXheaderValue, iEndLoc -
1)
strNewXheaderValue = "x-matter: " & CtlRegion.Matter
'user supplied value for xheader
strNewAllXheaderValue =
strOldAllXheaderValue.Replace(strOldXheaderValue, strNewXheaderValue)
sItem.Fields(PR_TRANSPORT_MESSAGE_HEADERS) =
strNewAllXheaderValue
sItem.Save()
AddTrace("Update to x-matter string done")
Else
Tag =
sItem.GetIDsFromNames("{00020386-0000-0000-C000-000000000046}", "X-Matter")
Tag = Tag Or &H1E 'the type is PT_STRING8
sItem.Fields(Tag) = CtlRegion.Matter & gblSeparator
'CtlRegion.Matter is user supplied value for xheader
'gblSeparator is "<;;;>"
sItem.Subject = sItem.Subject 'to trick Outlook into
thinking that something has changed
sItem.Save()
AddTrace("Added Xheader x-matter")
End If
Thanks
I need to monitor Inbox Items,if the item contains Xheader or not.I have one
command button
"save" on Read Msg Window form region.If the msg contains Xheader(say
x-matter) then
modify it with whatever value supplied by user,if the msg doesn't contain
Xheader then add xheader to that msg(x-matter) with value supplied by
user.I've Below code,it works if the
msg already has Xheader(x-matter) but not if the msg doesn't have
xheader(x-matter)
Dim PR_TRANSPORT_MESSAGE_HEADERS As String = &H7D001E
Dim strOldAllXheaderValue, strNewAllXheaderValue,
strOldXheaderValue, strNewXheaderValue As String
Dim iStartLoc, iEndLoc As Integer
sItem = CreateObject("Redemption.SafeMailItem")
sItem.Item = MailItem
strOldAllXheaderValue =
sItem.Fields(PR_TRANSPORT_MESSAGE_HEADERS)
strNewAllXheaderValue = strOldAllXheaderValue
iStartLoc = InStr(strOldAllXheaderValue, "x-matter",
CompareMethod.Text)
If iStartLoc > 0 Then strOldXheaderValue =
Mid(strOldAllXheaderValue, iStartLoc)
iEndLoc = InStr(strOldXheaderValue, gblSeparator)
'gblSeparator is "<;;;>"
AddTrace("EndLoc:" & iEndLoc)
If iStartLoc > 0 And iEndLoc > 0 Then
strOldXheaderValue = Left(strOldXheaderValue, iEndLoc -
1)
strNewXheaderValue = "x-matter: " & CtlRegion.Matter
'user supplied value for xheader
strNewAllXheaderValue =
strOldAllXheaderValue.Replace(strOldXheaderValue, strNewXheaderValue)
sItem.Fields(PR_TRANSPORT_MESSAGE_HEADERS) =
strNewAllXheaderValue
sItem.Save()
AddTrace("Update to x-matter string done")
Else
Tag =
sItem.GetIDsFromNames("{00020386-0000-0000-C000-000000000046}", "X-Matter")
Tag = Tag Or &H1E 'the type is PT_STRING8
sItem.Fields(Tag) = CtlRegion.Matter & gblSeparator
'CtlRegion.Matter is user supplied value for xheader
'gblSeparator is "<;;;>"
sItem.Subject = sItem.Subject 'to trick Outlook into
thinking that something has changed
sItem.Save()
AddTrace("Added Xheader x-matter")
End If
Thanks