Tag Archives: MFC MAPI

MAPI Developer: Download latest MFCMAPI from the Github


As you aware that MFCMAPI provides access to MAPI stores to facilitate investigation of Exchange and Outlook issues and to provide developers with a sample for MAPI development. If you look to download the latest MFCMAPI (x86/x64) then you can get it from the Github @ https://github.com/stephenegriffin/mfcmapi

Le Café Central de DeVa - MFCMAPI

Hope this helps.

Step-by-Step : Accessing Exchange mailbox using Exchange MAPI/CDO and MFCMAPI


One of my customer updated that he downloaded the MFCMAPIat his Exchange Server 2010/2013, when he ran he noticed the following error – he wanted to access the exchange mailbox programmatically.

Le Café Central de Deva - Deva blogs

Then he noticed the following error as well:

Le Café Central de Deva - Deva blogs

To start with he needs Exchange MAPICDO, as Microsoft Exchange MAPI and CDO 1.2.1 provide access to these APIs. As you know starting with Exchange Server 2007-Exchange Server 2013 , neither the Messaging API (MAPI) client libraries nor CDO 1.2.1 are provided as a part of the base product (Exchange) installation. As a result, there is functionality missing that many applications depend on. He can downloaded the latest Exchange MAPICDO (March 2014) from here.

Le Café Central de Deva - Deva blogs

After installing it, he need to create MAPI profile programmatically using his custom MAPI application or make use of Dave’s blog posts for profile creation using MFCMAPI (added below):
– for Exchange 2010 mailbox
– for Exchange 2013 mailbox
– same profile to use Exchange 2013 & legacy Exchange versions 

On successful profile creation, he successfully logged to the mailboxes correctly, access the data without any problem.

Le Café Central de Deva  - Deva blogs

Hope this helps.

MAPI Developers: Create profiles programmatically to connect Exchange 2013/Legacy Exchange versions, Office 365


As Stephen updated earlier, Dave had published series of blog posts (given below) which helps you to create Outlook profiles programmatically using MFCMAPI utility to connect Exchange Server 2013/legacy versions of Exchange, Office 365. Adding them for your reference.

How to use MFCMAPI to create a MAPI profile to connect to Exchange 2013 using latest version of MAPICDO? http://blogs.msdn.com/b/dvespa/archive/2013/05/21/how-to-mfcmapi-create-mapi-profile-exchange-2013.aspx

How to create an Outlook profile for Office 365 using Outlook MAPI? http://blogs.msdn.com/b/dvespa/archive/2014/01/17/how-create-outlook-profile-office-365.aspx

How to configure an Outlook profile using MFCMAPI for Exchange 2013 using Outlook MAPI? http://blogs.msdn.com/b/dvespa/archive/2014/01/16/create-outlook-profile-exchange-2013.aspx   

How to use the same profile to connect to both Exchange 2013 and legacy versions of Exchange Server using latest version of MAPICDO? http://blogs.msdn.com/b/dvespa/archive/2013/05/27/omniprof.aspx  

Note: You can download the latest MAPICDO (May 2013 update) from http://www.microsoft.com/en-us/download/details.aspx?id=39045

Hope this helps. Enjoy!!

 

Office Developer: How to programmatically restrict or filter “To” property using Outlook Object Model?


In this post, we will see how to programmatically filter/restrict items “To” property. Let we take this scenario. In Outlook, we notice it contains 6 items “To” property containing “Deva G”:  

Outlook UI

Note:In specifying a filter in a Jet or DASL query, if you use a pair of single quotes to delimit a string that is part of the filter, and the string contains another single quote or apostrophe, then add a single quote as an escape character before the single quote or apostrophe. Use a similar approach if you use a pair of double quotes to delimit a string. If the string contains a double quote, then add a double quote as an escape character before the double quote. For example, in the DASL filter string that filters for the Subject property being equal to the word can't, the entire filter string is delimited by a pair of double quotes, and the embedded string can't is delimited by a pair of single quotes. There are three characters that you need to escape in this filter string: the starting double quote and the ending double quote for the property reference of http://schemas.microsoft.com/mapi/proptag/0x0037001f, and the apostrophe in the value condition for the word can't. Applying the appropriate escape characters, you can express the filter string as follows:

filter = "@SQL=""http://schemas.microsoft.com/mapi/proptag/0x0037001f"" = 'can''t'"

Alternatively, you can use the chr(34) function to represent the double quote (whose ASCII character value is 34) that is used as an escape character. Using the chr(34) substitution for a double-quote escape character, you can express the last example as follows:

filter = "@SQL= " & Chr(34) & "http://schemas.microsoft.com/mapi/proptag/0x0037001f" & Chr(34) & " = " & "'can''t'"

For this above test, first we need to get the property reference for “to” so that we can create DASL Filter for it. For this, you can make use of latest MFC MAPI and get the same using its Property Editor.

MFC MAPI - Property Editor

I am making use of Outlook Object Model (OOM) API to filter/restrict “To” field items containing “Deva G”. In order to do that, you can make use of Items.Restrict method provided in OOM along with the Filter that you want to apply. The Restrict method is significantly faster if there is a large number of items in the collection, especially if only a few items in a large collection are expected to be found.

Filter = "@SQL= " & Chr(34) & "http://schemas.microsoft.com/mapi/proptag/0x0E04001E" & Chr(34) & " = " & "'Deva G'"

Using the above filter, we can build the code using Items.Restrict method – enclosing the Outlook VBA sample for your reference:

'**********************

'Using Items.Restrict

'**********************

 

Public Sub RestrictFilter()

 

Dim myNameSpace As Outlook.NameSpace

Dim myItems As Outlook.Items

Dim currentItem As Outlook.Items

Dim Filter As String

Dim i As Integer

 

Filter = "@SQL= " & Chr(34) & "http://schemas.microsoft.com/mapi/proptag/0x0E04001E" & Chr(34) & " = " & "'Deva G'"

Set myNameSpace = Application.GetNamespace("MAPI")

Set myItems = myNameSpace.PickFolder.Items

Set currentItem = myItems.Restrict(Filter)

For i = currentItem.Count To 1 Step -1

    Debug.Print currentItem(i).Subject

Next

 

End Sub

When you execute the code, you can retrieve the filtered item’s “subject” property values(PR_SUBJECT)….

Outlook VBA - Source code & Output

You can give a try and let me know how it goes…. Happy programming!!

Outlook : How to regenerate free/busy information using MFC MAPI?


Recently one of my customer reported that Outlook is not showing latest free/busy information for selected users.

Initially they tried the following steps for the affected users:
Exit Outlook
Open Command prompt > Open Outlook with cleanfreebusy switch (outlook.exe /cleanfreebusy)
It failed to resolve the issue.  

During troubleshooting we noticed that these issue may occur because a mailbox property does not correctly reference a hidden message in the mailbox, which is related to free/busy publishing.

We tried the below steps for the affected user to re-generate free/busy information:

Exit Outlook.
Make sure that the profile is in online mode. You can change this or create new one using Mail item in Control Panel.
Download latest MFC MAPI editor (http://mfcmapi.codeplex.com)
Start the MFCMAPI.exe >  click OK.  

image

On the Session menu, click Logon.
In the Profile Name list, select the profile for the mailbox, and then click OK.
Double-click the Mailbox Store.
In the navigation pane, click Root Container.

image

In the details pane, right-click PR_FREEBUSY_ENTRYIDS, click Delete Property, and then click OK.
In the navigation pane, expand Root Container, expand Top of Information Store, and then click Inbox.
In the details pane, right-click PR_FREEBUSY_ENTRYIDS, click Delete Property, and then click OK.

image

In the Information Store: Inbox dialog box, click Exit on the File menu.
Exit MFC MAPI.

Finally at Windows, you should click Start, click Run, type outlook.exe /cleanfreebusy, and then press ENTER – this will regenerate the free/busy information for that specific user mailbox.

image

Hope this helps.

MFC MAPI: How to view GAL entries


You can download the latest MFC MAPI utility to view GAL entries, which uses the Messaging API to provide access to MAPI stores through a graphical user interface.

Try the following steps:

1) Open MFC MAPI utility. Select Session menu and select “Logon and Display  Store table” ( I chosen for this session). It will ask you prompt the profile.

image

2) Select the profile. Once you select it, it will open the stores associated with it.

image

3) Select Address Book Menu and select "Open Default Directory” option

image

4) It will list out the GAL entries

image

5) If you select a GAL entry in the top pane, it will display its associated properties, tag, type, value etc in its below pane.

image

“MAPI_E_FAILONEPROVIDER” when you try to connect to a mailbox on an Exchange 2010 from an Exchange 2003 server


Recently one of my customer updated that when he tried connecting to a mailbox that is located on a  Exchange Server 2010 from Exchange Server 2003 by using a custom MAPI/C++ application. But it failed and it thrown the following error message: “MAPI_E_FAILONEPROVIDER”.

As part of troubleshooting the issue, we tried using MFC MAPI utility and can reproduce the issue. During troubleshooting, we found that this issue occurs because the MAPI subsystem on an Exchange Server 2003 server is not designed to be used on an Exchange Server 2010 server.

To resolve this issue, we recommended to use the following Exchange MAPI subsystem on an Exchange Server 2010 server/on a Exchange Server 2007 server.

Please note that the Exchange MAPI client and Collaboration Data Objects (CDO) 1.2.1 can be installed only on Exchange 2007 and Exchange 2010 servers. Additionally, it includes the MAPI client libraries and supports CDO 1.2.1. However, you cannot install this download on an Exchange 2003 server.

Download:

1) You can download the MAPI Sub system @ Microsoft Exchange Server MAPI client and Collaboration Data Objects 1.2.1

2) You can download the MFC MAPI Utility @ http://mfcmapi.codeplex.com/