I want to read an Outlook Business card .msg; I can read the values of Firstname, Lastname, email, Work Phone correcty, but not the values of Fax, mobile phone, …
First, I tried to use MapiContact but the Contact details was NULL
MapiMessage message = MapiMessage.FromFile(fileName);
// Get all named MAPI properties
MapiPropertyCollection properties = message.NamedProperties;
StringBuilder sb = new StringBuilder();
foreach (MapiNamedProperty mapiNamedProp in properties.Values)
{
// Read any specific property
string val = string.Format("{0} = {1}", mapiNamedProp.NameId, mapiNamedProp.GetString());
sb.AppendLine(val);
}
I have analyzed the code and found that wrong properties are used in the code w.r.t sample msg file. There are two properties PR_BUSINESS_FAX_NUMBER_W and PR_MOBILE_TELEPHONE_NUMBER_W in the current sample msg file where as you are using properties which were sent with the previous example as given below:
PR_BUSINESS_TELEPHONE_NUMBER
PR_BUSINESS_FAX_NUMBER
PR_MOBILE_TELEPHONE_NUMBER
In order to use the sample msg file in your example code, please modify your code as given below:
//lblInfo.Text += " Business 2 = " + message.Properties[MapiPropertyTag.PR_BUSINESS_TELEPHONE_NUMBER]; //blInfo.Text += " Business Fax = " + message.Properties[MapiPropertyTag.PR_BUSINESS_FAX_NUMBER]; //lblInfo.Text += " Mobile No = " + message.Properties[MapiPropertyTag.PR_MOBILE_TELEPHONE_NUMBER];
lblInfo.Text += " Business Fax = " + message.Properties[MapiPropertyTag.PR_BUSINESS_FAX_NUMBER_W]; lblInfo.Text += " Mobile No = " + message.Properties[MapiPropertyTag.PR_MOBILE_TELEPHONE_NUMBER_W]; For your kind reference it was suggested that Outlook Spy should be used for identifying the required properties from a msg file. When this software is installed, a menu option is added to your Outlook installation.as shown in attached screen shot MessageOpenedInOutlook.png.
When we open this OutlookSpy page, a button IMessage is displayed as shown in screen shot OutlookSpyOpened.PNG.
Finally we can identify the required properties from the list as shown in the screen shot PropertiesInOutlookSpy.PNG. The same properties are suggested to be used in the sample code.
I hope this explanation will be helpful for you to identify different properties from any msg file opened in the OutlookSpy.
If you have any other query please feel free to write us back.