none
Usage of IMsgServiceAdmin2 failed RRS feed

  • Question

  • Hi,

    I'm working on an old code base. Following the links below, I'm trying to modify the logic and call CreateMsgService.

    Compilation goes fine but fails during linking.

    I end up with the "error LNK2001: unresolved external symbol _IID_IMsgServiceAdmin2"

    https://blogs.msdn.microsoft.com/stephen_griffin/2010/09/27/september-2010-release-of-mfcmapi/

    https://searchcode.com/codesearch/view/3372621/

    I've MAPIAux.h included and also mapi32.lib in linker options. Not sure where/what I am doing wrong.

    Can someone share any hints?

    Below is the code snippet

        hr = pProfAdmin->CreateProfile(const_cast<char *>(sProfile.c_str()), NULL, 0, 0);
        if (!checkHR(hr, "pProfAdmin->CreateProfile", rLog))
            return false;
    
        rLog << APPLOG_LEVEL_NORMAL << "Created messaging profile '" << sProfile << "'" << std::endl; 
    
        CComPtr<IMsgServiceAdmin> pMsgServiceAdmin;
        hr = pProfAdmin->AdminServices(const_cast<char *>(sProfile.c_str()), NULL, 0, 0, &pMsgServiceAdmin);
    
    	if (!pMsgServiceAdmin || !checkHR(hr, "pProfAdmin->AdminServices", rLog))
    	{
    		profileDeleteInt(pProfAdmin, sProfile.c_str(), &rLog);
    		return false;
    	}
    
    	CComPtr<IMsgServiceAdmin2> pMsgServiceAdmin2 = NULL;
    	hr = pMsgServiceAdmin->QueryInterface(IID_IMsgServiceAdmin2, (LPVOID*)&pMsgServiceAdmin2);
    
    	if (!pMsgServiceAdmin2 || !checkHR(hr, "pMsgServiceAdmin->QueryInterface{IMsgServiceAdmin2}", rLog))
    	{
    		if (!addPSTToProfile(rsPST, pMsgServiceAdmin, rLog))
    		{
    			profileDeleteInt(pProfAdmin, sProfile.c_str(), &rLog);
    			return false;
    		}
    	}
    	else
    	{
    		MAPIUID uidService = { 0 };
    		LPMAPIUID lpuidService = &uidService;
    
    		if (!addPSTToProfile2(rsPST, pMsgServiceAdmin2, lpuidService, rLog))
    		{
    			profileDeleteInt(pProfAdmin, sProfile.c_str(), &rLog);
    			return false;
    		}
    	}


    Sai






    • Edited by sgdokku Monday, July 3, 2017 8:42 AM removed tags
    Monday, July 3, 2017 6:39 AM

Answers

  • Try this -

    #define USES_IID_IMsgServiceAdmin2
    #define INITGUID
    #include <guiddef.h>
    #include <MAPIAux.h>
    

    • Marked as answer by sgdokku Monday, July 3, 2017 10:50 AM
    Monday, July 3, 2017 9:35 AM

All replies

  • Hi,
    https://searchcode.com/codesearch/view/3372621/

    I'm trying to modify the logic and call CreateMsgServiceEx. Code compiles fine but fails during linking. I end up with the "error LNK2001: unresolved external symbol _IID_IMsgServiceAdmin2"

    I've MAPIAux.h included and also mapi32.lib in linker options. Not sure where/what I am doing wrong. Can someone share any hints?
    Below is the code snippet
    /**********************************************
        * create a temporary profile 
        **********************************************/
        hr = pProfAdmin->CreateProfile(const_cast<char *>(sProfile.c_str()), NULL, 0, 0);
        if (!checkHR(hr, "pProfAdmin->CreateProfile", rLog))
            return false;
    
        rLog << APPLOG_LEVEL_NORMAL << "Created messaging profile '" << sProfile << "'" << std::endl; 
    
        /**********************************************
        * Get IMsgServiceAdmin of the just created profile 
        * so that we can make changes to the message services in a profile
        **********************************************/
        CComPtr<IMsgServiceAdmin> pMsgServiceAdmin;
        hr = pProfAdmin->AdminServices(const_cast<char *>(sProfile.c_str()), NULL, 0, 0, &pMsgServiceAdmin);
    
    	if (!pMsgServiceAdmin || !checkHR(hr, "pProfAdmin->AdminServices", rLog))
    	{
    		profileDeleteInt(pProfAdmin, sProfile.c_str(), &rLog);
    		return false;
    	}
    
    	CComPtr<IMsgServiceAdmin2> pMsgServiceAdmin2 = NULL;
    	hr = pMsgServiceAdmin->QueryInterface(IID_IMsgServiceAdmin2, (LPVOID*)&pMsgServiceAdmin2);
    
    	if (!pMsgServiceAdmin2 || !checkHR(hr, "pProfAdmin->QueryInterface{IMsgServiceAdmin2}", rLog))
    	{
    		if (!addPSTToProfile(rsPST, pMsgServiceAdmin, rLog))
    		{
    			profileDeleteInt(pProfAdmin, sProfile.c_str(), &rLog);
    			return false;
    		}
    	}
    	else
    	{
    		MAPIUID uidService = { 0 };
    		LPMAPIUID lpuidService = &uidService;
    
    		if (!addPSTToProfile2(rsPST, pMsgServiceAdmin2, lpuidService, rLog))
    		{
    			profileDeleteInt(pProfAdmin, sProfile.c_str(), &rLog);
    			return false;
    		}
    	}
    	



    Sai


    Monday, July 3, 2017 5:01 AM
  • Try this -

    #define USES_IID_IMsgServiceAdmin2
    #define INITGUID
    #include <guiddef.h>
    #include <MAPIAux.h>
    

    • Marked as answer by sgdokku Monday, July 3, 2017 10:50 AM
    Monday, July 3, 2017 9:35 AM
  • Hi Sai,

    Thanks for visiting our forum.

    Then here we mainly focus on general questions about Outlook client. As your issue is more related to developing issues involving Outlook, we'll move your thread to the following dedicated MSDN forum for Outlook:

    https://social.msdn.microsoft.com/Forums/en-US/home?forum=outlookdev

    The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding.

    Best regards,
    Yuki Sun


    Please remember to mark the replies as answers if they helped.

    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.


    Wednesday, July 5, 2017 6:14 AM