Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. MAPI/CDO from an NT Service

MAPI/CDO from an NT Service

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialquestionlearning
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    thowra
    wrote on last edited by
    #1

    I've got some confusing code to try and fix. It appears to be using CDO to send a message and it works fine from the command line. however, from an NT service it fails due a MAPI Logon error. I know this is usually to do with the profile, but I now think it's down to CDO as if I replace the CDO logon code with a standard MAPILogonEx() call, it logs on with no problem. I guess it may be down to the parameter the previous developer wasn't passing in at logon time, for example, MAPI_NT_SERVICE. I don't know how to do this in CDO and I cannot find any documentation. Can anyone help? Can anyone suggest any links to info? Here's a brief summary of the code I need to get working: 1. CLSIDFromPogID() returns "MAPI.Session" CLSID. 2. CoCreateInstance() on the MAPI CLSID returns IDispatch interface. 3. Calls the Logon() method on the IDispatch interface with several parameters (this is where I believe I should be able to pass my extra parameters), but how? 4. Call GetIDsOfNames() to get the DISPID for the method required. 5. Call IDispatch::Invoke() with the named member ID "The folly of man is that he dreams of what he can never achieve rather than dream of what he can." "If you think education is expensive, try ignorance."

    M 1 Reply Last reply
    0
    • T thowra

      I've got some confusing code to try and fix. It appears to be using CDO to send a message and it works fine from the command line. however, from an NT service it fails due a MAPI Logon error. I know this is usually to do with the profile, but I now think it's down to CDO as if I replace the CDO logon code with a standard MAPILogonEx() call, it logs on with no problem. I guess it may be down to the parameter the previous developer wasn't passing in at logon time, for example, MAPI_NT_SERVICE. I don't know how to do this in CDO and I cannot find any documentation. Can anyone help? Can anyone suggest any links to info? Here's a brief summary of the code I need to get working: 1. CLSIDFromPogID() returns "MAPI.Session" CLSID. 2. CoCreateInstance() on the MAPI CLSID returns IDispatch interface. 3. Calls the Logon() method on the IDispatch interface with several parameters (this is where I believe I should be able to pass my extra parameters), but how? 4. Call GetIDsOfNames() to get the DISPID for the method required. 5. Call IDispatch::Invoke() with the named member ID "The folly of man is that he dreams of what he can never achieve rather than dream of what he can." "If you think education is expensive, try ignorance."

      M Offline
      M Offline
      Mike Dimmick
      wrote on last edited by
      #2

      Windows does not load the user's configured profile when logging on as a service. This may be the source of your problem. You could try calling LoadUserProfile before calling Logon.

      T 1 Reply Last reply
      0
      • M Mike Dimmick

        Windows does not load the user's configured profile when logging on as a service. This may be the source of your problem. You could try calling LoadUserProfile before calling Logon.

        T Offline
        T Offline
        thowra
        wrote on last edited by
        #3

        No, I'm definitely specifying the user profile and password if necessary. They are passed as the first two parameters to the Logon method via MAPI's IDispatch interface. I know it works just fine as an NT service because, as I said, replacing the CDO code with Extended MAPI, works fine. Unfotunately, if I were to use Extended MAPI there is a lot of extra work to do replacing all the existing code... "The folly of man is that he dreams of what he can never achieve rather than dream of what he can." "If you think education is expensive, try ignorance."

        M 1 Reply Last reply
        0
        • T thowra

          No, I'm definitely specifying the user profile and password if necessary. They are passed as the first two parameters to the Logon method via MAPI's IDispatch interface. I know it works just fine as an NT service because, as I said, replacing the CDO code with Extended MAPI, works fine. Unfotunately, if I were to use Extended MAPI there is a lot of extra work to do replacing all the existing code... "The folly of man is that he dreams of what he can never achieve rather than dream of what he can." "If you think education is expensive, try ignorance."

          M Offline
          M Offline
          Mike Dimmick
          wrote on last edited by
          #4

          Sorry, I mean 'user's profile' in the sense of the registry entries under HKEY_USERS and mapping HKEY_CURRENT_USER to the appropriate key under HKEY_USERS. This is not done for a batch, service or network logon, it's only done by USERENV.EXE for an interactive logon.

          T 1 Reply Last reply
          0
          • M Mike Dimmick

            Sorry, I mean 'user's profile' in the sense of the registry entries under HKEY_USERS and mapping HKEY_CURRENT_USER to the appropriate key under HKEY_USERS. This is not done for a batch, service or network logon, it's only done by USERENV.EXE for an interactive logon.

            T Offline
            T Offline
            thowra
            wrote on last edited by
            #5

            That's not a problem. I specify the MAPI_EXPLICIT_PROFILE flag. All I need to do then is specify a valid profile and password if required. "The folly of man is that he dreams of what he can never achieve rather than dream of what he can." "If you think education is expensive, try ignorance."

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups