![]() |
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
![]()
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 |
#2
|
|||
|
|||
![]()
Do you get any errors?
Do you get the expected value from GetIDsFromNames? Outlook might not see your changes, try to add the following line before you call sItem.Save MailItem.Subject = MailItem.Subject Dmitry Streblechenko (MVP) http://www.dimastr.com/ OutlookSpy - Outlook, CDO and MAPI Developer Tool "shubhangi" wrote in message ... 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 |
#3
|
|||
|
|||
![]()
Thanks for reply!
No I don't get any error.I can see expected xheader value with GetIDsFromNames. But When I dump "PR_TRANSPORT_MESSAGE_HEADERS" ,I could not see my xheader there.I also added before sItem.Save.But Invain! MailItem.Subject = MailItem.Subject before Thanks again "Dmitry Streblechenko" wrote in message ... Do you get any errors? Do you get the expected value from GetIDsFromNames? Outlook might not see your changes, try to add the following line before you call sItem.Save MailItem.Subject = MailItem.Subject Dmitry Streblechenko (MVP) http://www.dimastr.com/ OutlookSpy - Outlook, CDO and MAPI Developer Tool "shubhangi" wrote in message ... 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 |
#4
|
|||
|
|||
![]()
Your custom header will not be automatically added to
PR_TRANSPORT_MESSAGE_HEADERS. Why do you expect that to happen? It is your responsibily to modiy PR_TRANSPORT_MESSAGE_HEADERS explicitly for a received message. Dmitry Streblechenko (MVP) http://www.dimastr.com/ OutlookSpy - Outlook, CDO and MAPI Developer Tool "shubhangi" wrote in message ... Thanks for reply! No I don't get any error.I can see expected xheader value with GetIDsFromNames. But When I dump "PR_TRANSPORT_MESSAGE_HEADERS" ,I could not see my xheader there.I also added before sItem.Save.But Invain! MailItem.Subject = MailItem.Subject before Thanks again "Dmitry Streblechenko" wrote in message ... Do you get any errors? Do you get the expected value from GetIDsFromNames? Outlook might not see your changes, try to add the following line before you call sItem.Save MailItem.Subject = MailItem.Subject Dmitry Streblechenko (MVP) http://www.dimastr.com/ OutlookSpy - Outlook, CDO and MAPI Developer Tool "shubhangi" wrote in message ... 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 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
update xheader | shubhangi | Add-ins for Outlook | 1 | October 18th 07 06:48 PM |
update xheader of received message | sd[_2_] | Outlook and VBA | 5 | October 18th 07 05:58 PM |
How do I stop a message received notification that won't go thru | TRG | Outlook - Installation | 1 | November 24th 06 07:01 PM |
No sound when message received | ChelseaWarren | Outlook Express | 3 | August 21st 06 01:32 PM |
Message received by recipient not clear | carlo | Outlook Express | 4 | July 1st 06 09:25 PM |