问题
Our client is using Microsoft CRM 2011 outlook client and they have a unique business need. They want to make the "Set Regarding" mandatory for all of their employees using outlook to send emails (Weird huh?). If a user while sending the email forget to set regarding, outlook should display a notification message and shouldn't let the user send the email.
I have not been able to find any out of the box feature for this so I decided to write an outlook addin. Is there a way to know in outlook addin ItemSend event that the mail item has the value set for regarding field? I can get the subject of the email including CRM:xxxxx but since the email is not yet created in CRM I don't know how to pull the regarding data.
回答1:
The information about the tracking are stored in the MAPI-properties of the mail. See the attached screenshot. They should be accessible in the ItemSend event.
You could get this information like this (from @Ahmeds comment)
dynamic regardingId = mailItem.PropertyAccessor.GetProperty("schemas.microsoft.com/mapi/string/;{00020329-0000-0000-C000-000000000046}/crmRegardingId/0x0000001F");
回答2:
I used following code in VS2012 and outlook 2010 to get the regarding GUID.
dynamic id = mailItem.UserProperties["crmRegardingId"];
if (id != null) Console.Write(id.Value);
else Console.Write("Error");
来源:https://stackoverflow.com/questions/9836718/crm-2011-outlook-client-set-regarding-mandatory