How to differentiate incoming mail where subjects have same beginning text? - regex

I have created a rule where the subject line contains
A Document has been assigned to You
It also routes the emails with subject
A Document has been assigned to Your group
How can I fix this? Is there a regular expression available?

You can develop a VBA macro that can handle incoming emails. The NewMailEx event fires once for every received item that is processed by Microsoft Outlook. The item can be one of several different item types, for example, MailItem, MeetingItem, or SharingItem. The EntryIDsCollection string contains the Entry ID that corresponds to that item.
The NewMailEx event fires when a new message arrives in the Inbox and before client rule processing occurs. You can use the Entry ID returned in the EntryIDCollection array to call the NameSpace.GetItemFromID method and process the item. Use this method with caution to minimize the impact on Outlook performance.
Public WithEvents outApp As Outlook.Application
Sub Intialize_Handler()
Set outApp = Application
End Sub
Private Sub outApp_NewMailEx(ByVal EntryIDCollection As String)
Dim mai As Object
Set mai = Application.Session.GetItemFromID(EntryIDCollection)
MsgBox mai.Subject
End Sub
You can use regular expression in VBA macros, see How to Use/Enable (RegExp object) Regular Expression using VBA (MACRO) in word for more information.

Related

Get only MQ9 messages that belong to a group "2" in C++

I am trying to use IBM MQ client 9 with C++. I would like to read only messages that has group id '2'. I have tried everything but it just does not work. Can someone assist please?
I tried to set groupId and flag to match on group.
MQGET
gmoptions.setMatchOptions(MQMO_MATCH_GROUP_ID);
MQBYTE24 bGroupId("2");
ImqBinary _groupId;
_groupId.set(bGroupId, sizeof(bGroupId));
message.setGroupId(_groupId);
q->get(message, gmoptions);
MQPUT
MQBYTE24 bGroupId("2");
ImqBinary _groupId;
_groupId.set(bGroupId, sizeof(bGroupId));
message.setGroupId(_groupId);
ImqPutMessageOptions pmo;
pmo.setOptions(MQPMO_LOGICAL_ORDER);
pmo.setRecordFields(MQPMRF_GROUP_ID);
q->put(message, pmo);
mqget should be able to get all the msgs with groupId "2" but it does not. Though it can read the msg as soon as I remove setMatchOptions.
Basically, I want to use Group Id as filter where server instance 1 will read msgs only in group1 and server instance 2 will read msgs only in group 2 and so on, instead of creating separate queues for each server instance.
May be following can help me if group id is only for batching instead of filtering though not sure how to do 'Selection using the MQSUB and MQOPEN function calls' in C++
https://www.ibm.com/support/knowledgecenter/SSFKSJ_9.0.0/com.ibm.mq.dev.doc/q022990_.htm
Is there any C++ equivalent of MQSETMP ? I am unable to find any interface in ImqQueue or ImqObject that will let me set message property or selectionString.
I don't think you are going about this the right way.
IBM published a Java/MQ sample program to get messages in a group called GetGroup.java. You can find it here. You can use it as a model for your C++ program.
Basically, the code retrieves a message from the queue and then checks the messageFlags field if the message is part of a group.
if ((myMessage.messageFlags & CMQC.MQMF_MSG_IN_GROUP) == CMQC.MQMF_MSG_IN_GROUP)
If the message is part of the group then the code sets the matchOptions for matching on a group and retrieves all of the messages in the group.
Note: You will probably want to add logical order to the GMO options.
gmo.options |= CMQC.MQGMO_LOGICAL_ORDER;
Finally, what is this?
pmo.setRecordFields(MQPMRF_GROUP_ID);
That doesn't make any sense. You should be setting messageFlags field to MQMF_MSG_IN_GROUP.
You can use the concept of SELECTORS in IBM MQ. A message selector is a variable-length string used by an application to register its interest in only those messages that have properties that satisfy the Structured Query Language (SQL) query that the selection string represents.
A message selector is a concept that has been in the JMS specification for a long time. It
is a way of limiting the messages that are passed to an application to those that meet
certain criteria. Those criteria are based on the values of the message properties and only
the value of the message properties. It is important to understand that selection cannot be
based on any values of the message payload, only on the message property values.
In your case, the PUT application will have to put messages with populating the a certain topic string in MQMD or MQRFH2 header and using MQ Interface function calls, you should be able to pick the messages only with a certain value which in your case is GroupId value.
Below are few reference links to the concept:
https://www.ibm.com/support/knowledgecenter/SSFKSJ_7.5.0/com.ibm.mq.dev.doc/q022990_.htm
http://publib.boulder.ibm.com/infocenter/ieduasst/v1r1m0/topic/com.ibm.iea.wmq_v7/wmq/7.0/MQI/iea_330_wmqv7_API_3_Selectors.pdf ==> Pdf gets downloaded
To understand Message Properties => https://www.ibm.com/support/knowledgecenter/en/SSFKSJ_8.0.0/com.ibm.mq.dev.doc/q022920_.htm

Google Tag Manager Trigger using RegEx

I'm troubleshooting an event that uses an 'All Elements' trigger associated to a 'Click Class' lookup table.
The lookup table has four input values corresponding to classes added to target HTML elements. The event needs to fire when any target element is clicked.
From what I can determine through testing, if a clicked element has more than one class (including one of the target click classes), the Lookup table as I've configured it does not receive the value (the eventLabel holds the lookup variable is null) and the trigger does not fire. I've verified that the class is present in the datalayer, in the click class variable.
The LookUp table passes unique output values for each input, and the trigger has a simple regex, as follows:
Trigger fires when 'My LookUp Variable' matches RegEx (ignore case) heading|button|image
The only time it fires is when the heading is clicked -- this is the element that has only the target class. All other elements have other classes in addition to the target class.
Also, I'd use click ID for this but the target elements exist within a search result component that appears many times on the webpage. Hence, use of the ID attribute would be semantically incorrect.
Anyway...any help here would be appreciated.

Excel Interop: Grouping columns

How do i group columns using Excel interop?
if i record a macro (usually a good way to get started) i get this code:
Columns("I:M").Select
Selection.Columns.Group
unfortunately this doesn't work due to several problems, at least in C++. First of all, Application.Selection returns a normal Range, then Range.Columns is another Range. And Range.Group is this method:
http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.range.group%28v=office.11%29.aspx
This method only works in connection with pivot tables.
So how do i create a column group using Excel interop?
Even if i manage to create a group, how can i shrink/expand it? By that i mean clicking on the + to show the content of the group, or rather the other way around, "click" on the minus to hide the group. If i do that while recording a macro, it is not reflected in the macro at all.
Despite the fact that the Range.Group() documentation appears to relate to pivot tables, if you extract the columns using Range.Columns, and then apply the .Group() method to that range, it will have the desired effect. In C#:
Range range = sheet.get_Range("c1","e1");
range.Columns.Group();
Edit: The complete example, again in C# (apologies, it's the example I have handy):
Microsoft.Office.Interop.Excel.Application app = new Microsoft.Office.Interop.Excel.Application();
app.Visible = true;
app.Workbooks.Add();
Worksheet sheet = app.Workbooks[1].Sheets[1];
Range range = sheet.get_Range("c1","e1");
range.Columns.Group();
One thing the macro recorder obscures is the need to use the Range.EntireColumn property. Here's some code that groups, expands and collapses. I got this by googling and fooling around, but I think it gets the concepts right. Hopefully it's easy to translate into C++:
Sub test()
Dim ws As Excel.Worksheet
Set ws = ActiveSheet
With ws
If .Columns.OutlineLevel > 1 Then
'clear any existing hidden grouped columns and grouping
.Outline.ShowLevels columnlevels:=.Columns.OutlineLevel
.Range("1:1").EntireColumn.Ungroup
End If
'group
.Range("A:C").EntireColumn.Group
'collapse
ws.Outline.ShowLevels columnlevels:=1
'expand
ws.Outline.ShowLevels columnlevels:=.Columns.OutlineLevel
End With
End Sub

Repeating groups in quickfix/c++

I am writing a program that uses the quickfix library. The documentation is very poor, so I am requesting the help of SO fellows.
I have seen in the Group class that there are iterators. So I suppose that there is some STL-ish way of parsing repeating groups. Am I wrong?
Can anybody provide a simple example for doing that?
Thank you very much in advance.
Use Quickfix library alongwith the documentation of how FIX messages are constructed. Else it would be very difficult to decipher how the messages are organized.
This is an example from Quickfix website
Your message is the MarketDataSnapshotFullRefresh class object.
FIX::NoMDEntries noMDEntries;
message.get(noMDEntries); ->
You get the count of repeating groups, how many times you need to iterate over the object message to get all the entries. Remember FIX::NoMDEntries is a field.
FIX42::MarketDataSnapshotFullRefresh::NoMDEntries group; ->
This is a little tricky. You go inside a message to get the groups. Here NoMDEntries is an enclosed class inside MarketDataSnapshotFullRefresh class. Remeber this is the class which will give you the data. Now either you run through a loop or write the same code multiple times to extract all the fields inside each group. getGroup gives you the group from which you extract fields. getField will give you the field data. Most of the nomenclature of Quickfix is FIX messages. So refer a FIX message website like Fiximate and your life will be much easier.
FIX::MDEntryType MDEntryType;
FIX::MDEntryPx MDEntryPx;
FIX::MDEntrySize MDEntrySize;
FIX::OrderID orderID;
message.getGroup(1, group);
group.get(MDEntryType);
group.get(MDEntryPx);
group.get(MDEntrySize);
group.get(orderID);
message.getGroup(2, group);
group.get(MDEntryType);
group.get(MDEntryPx);
group.get(MDEntrySize);
group.get(orderID);
There are iterators in FieldMap class which is a super class of Message and Group class.
I'm not sure what do you mean by parsing repeating groups.
Fix engine parses raw fix messages for you when they arrive and your callback gets parsed FIX message - which has internal maps of tags (key/value) for tags in message header, body and tail.
Looking at 1.13.2 version of code, when the engine gets new string message from network it will eventually create a Message passing it the string. Message constructor then calls setString() on itself which effectively parses the received string and creates a map of tags.
If you look at Message::setString you can see that first the new field is added and then in setGroup it checks if the field is part of the group. If it is then this method, setGroup, takes over parsing of the following tags while those tags are part of the group. Once it comes across of tag that is not part of the group it stops parsing the group, it returns and continues parsing fields from message.
Now this all happens internally before the callback to your app where you handle received message.
There is a way to iterate over fields in a message. You can iterate over fields of header, body or over groups (and over each group).
const FIX40::ExecutionReport& msg; // new incoming message
// iterate over header
FIX::FieldMap::iterator it;
FIX::FieldMap::iterator b = msg.getHeader().begin();
FIX::FieldMap::iterator e = msg.getHeader().end();
for(it = b; it != e; ++it)
{
switch(it->first)
{
case FIX::FIELD::MsgSeqnum:
/* it->second.getString() - do something with tag data*/ ;
break;
...
}
}
And similarly for body:
FIX::FieldMap::iterator it;
FIX::FieldMap::iterator b = msg.begin();
FIX::FieldMap::iterator e = msg.end();
And there is groups iterator (FieldMap::g_begin/g_end) as well so you could iterate over groups in msg or header and you can similarly iterate, or search, tags within each group.
Group as well as Message extends FieldMap so all the getField/setField functionality is shared across.
Internals ... skip if too much detail.
In the above example this code:
message.getGroup(1, group);
group.get(MDEntryType);
Effectively passes the call from message.getGroup(1, group) -> FieldMap::getGroup(1, group.field(), group) -> getGroupRef(num,field) -> m_groups.find(field) which gives you a vector of groups (vector<FieldMap*>) and returns the num element, aka the num group from the message (a FieldMap).
group.get(field) is created using macros for each tag which is effectively translated as (map).getField(field).
During initialization the (map) for group is a reference to the object of which the tag is member of so it returns the tag from the specific group (see example src/C++/fix44/NewOrderSingle.h it has couple of internal classes which extend Group)
Hope that it makes some sense.

SharePoint UserData and the ;# Syntax in returned data

Can a SharePoint expert explain to me the ;# in data returned by the GetListItems() call to the Lists web service?
I think I understand what they are doing here. The ;# is almost like a syntax for making a comment... or better yet, including the actual data (string) and not just the ID. This way you can use either, but they are nicely paired together in the same column.
Am I way off base? I just can't figure out the slighly different use. For example
I have a list with:
ows_Author
658;#Tyndall, Bruno
*in this case the 658 seems to be an ID for me in a users table somewhere*
ows_CreatedDate (note: a custom field. not ows_Created)
571;#2009-08-31 23:41:58
*in this case the 571 seems to be an ID of the row I'm already in. Why the repetition?*
Can anyone out there shed some light on this aspect of SharePoint?
The string ;# is used as a delimiter by SharePoint's lookup fields, including user fields. When working with the object model, you can use SPFieldLookupValue and SPFieldUserValue to convert the delimited string into a strongly-typed object. When working with the web services, however, I believe you'll need to parse the string yourself.
You are correct that the first part is an integer ID: ID in the site user list, or ID of the corresponding item in the lookup list. The second part is the user name or value of the lookup column.
Nicolas correctly notes that this delimiter is also used for other composite field values, including...
SPFieldLookupValueCollection
SPFieldMultiColumnValue
SPFieldMultiChoiceValue
SPFieldUserValueCollection
The SPFieldUser inherits from the SPFieldLookup which uses the ;# notation. You can easily parse the value by creating a new instance of the SPFieldLookupValue class:
string rawValue = "1;#value";
SPFieldLookupValue lookupValue = new SPFieldLookupValue(rawValue);
string value = lookupValue.LookupValue; // returns value