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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. urgent!

urgent!

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++
15 Posts 3 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.
  • D David Crow

    ranjjj wrote: the code works only iff outlook window is opened Take a look at MAPILogon(). Its parameters govern whether to use an existing session, or create a new one.


    Five birds are sitting on a fence. Three of them decide to fly off. How many are left?

    R Offline
    R Offline
    ranjjj
    wrote on last edited by
    #3

    how to create a new one.. i tried doing it.. but didn't work out.. after reading the message, the message is deleted from the inbox! ranjani

    D 1 Reply Last reply
    0
    • D David Crow

      ranjjj wrote: the code works only iff outlook window is opened Take a look at MAPILogon(). Its parameters govern whether to use an existing session, or create a new one.


      Five birds are sitting on a fence. Three of them decide to fly off. How many are left?

      R Offline
      R Offline
      ranjjj
      wrote on last edited by
      #4

      even when use the new session.. am able to read the mails only one at a time! and also.... in the MAPIFindNext function .... the fourth parameter being the pointer to the message identifier seed.. i'm [passing as Nul in the beginning to read the first unread mail.. how should i use it later?? ranjani

      D 1 Reply Last reply
      0
      • R ranjjj

        how to create a new one.. i tried doing it.. but didn't work out.. after reading the message, the message is deleted from the inbox! ranjani

        D Offline
        D Offline
        David Crow
        wrote on last edited by
        #5

        ranjjj wrote: how to create a new one..

        MAPILogon(0, NULL, NULL, MAPI_LOGON_UI, 0, &m_lhSession);


        Five birds are sitting on a fence. Three of them decide to fly off. How many are left?

        R 1 Reply Last reply
        0
        • D David Crow

          ranjjj wrote: how to create a new one..

          MAPILogon(0, NULL, NULL, MAPI_LOGON_UI, 0, &m_lhSession);


          Five birds are sitting on a fence. Three of them decide to fly off. How many are left?

          R Offline
          R Offline
          ranjjj
          wrote on last edited by
          #6

          i don't want a dialog box to be displayed.. logon_ui does that right?? and... the only problem now is.. it doesn't work out if the outlook window is not opened.. how to solve it..i tried using new sesion also..anddd..logon ui also.. it doesn't work! ranjani

          D 1 Reply Last reply
          0
          • R ranjjj

            even when use the new session.. am able to read the mails only one at a time! and also.... in the MAPIFindNext function .... the fourth parameter being the pointer to the message identifier seed.. i'm [passing as Nul in the beginning to read the first unread mail.. how should i use it later?? ranjani

            D Offline
            D Offline
            David Crow
            wrote on last edited by
            #7

            char sMessageId[512],
            sMessageSeed[512];
            int nReturn;

            sMessageId[0] = '\0';
            sMessageSeed[0] = '\0';

            nReturn = MAPIFindNext(m_lhSession, 0, NULL, sMessageSeed, MAPI_LONG_MSGID | MAPI_UNREAD_ONLY, 0, sMessageId);
            if (SUCCESS_SUCCESS == nReturn)
            {
            do
            {
            // read the message

                lstrcpy(sMessageSeed, sMessageId);        
                nReturn = MAPIFindNext(m\_lhSession, 0, NULL, sMessageSeed, MAPI\_LONG\_MSGID | MAPI\_UNREAD\_ONLY, 0, sMessageId);
            } while (SUCCESS\_SUCCESS == nReturn);
            

            }


            Five birds are sitting on a fence. Three of them decide to fly off. How many are left?

            R 1 Reply Last reply
            0
            • R ranjjj

              the following is a c++ program written to access the mailbox of the defaulkt mail client and read the mails ... i experimented te code only with outlook...as that is only configured in my machine..the code works only iff outlook window is opened ..also it displays only 1 read mail for 1 execution of thios code...i want to dispaly all unread mails at a time when i run this program once..what are hte necessary changes to be made in the program..can someone plzz kindly help me in this! #include #include #include #include #include #include #include #include //assumption::character interface being used. //the Simple MAPI functions for reading messages can't //log on implicitly and require an explicit session handle. /*the client application defines needed variables and logs on to get a session handle */ /*ULONG ReadNextUnreadMsg(void);*/ ULONG ReadNextUnreadMsg() { ULONG err; CHAR rgchMsgID[513]; // Message IDs should be >= 512 CHARs + a null. MapiMessage *lpMessage; // Used to get a message back from MAPIReadmail ULONG i; // Ubiquitous loop counter. int totalLength; int length; int LINE_WIDTH = 0; // Number of characters printed on a line. LHANDLE m_lhSession; // Need a session for MAPIFindNext. HINSTANCE hlibMAPI = LoadLibrary ( "MAPI32.DLL" ); LPMAPILOGON m_MAPILogon = (LPMAPILOGON)GetProcAddress(hlibMAPI, "MAPILogon"); LPMAPIFINDNEXT m_MAPIFindNext = (LPMAPIFINDNEXT) GetProcAddress (hlibMAPI, "MAPIFindNext"); LPMAPIREADMAIL m_MAPIReadMail = (LPMAPIREADMAIL) GetProcAddress (hlibMAPI, "MAPIReadMail"); LPMAPIFREEBUFFER m_MAPIFreeBuffer = (LPMAPIFREEBUFFER) GetProcAddress (hlibMAPI, "MAPIFreeBuffer"); LPMAPILOGOFF m_MAPILogoff = (LPMAPILOGOFF) GetProcAddress (hlibMAPI, "MAPILogoff"); err =m_MAPILogon(0L, // ulUIParam; 0 always valid. "Microsoft Outlook Internet Settings",// profile name to use when logging on NULL, // No password needed. 0L, // Use shared session. 0L, // Reserved; must be 0. &m_lhSession); // Session handle. if (err != SUCCESS_SUCCESS) // Make sure MAPILogon succeeded. { printf("Error: could not log on\r\n"); return(err); } //next..the client searches for the first unread message in the //default folder in the store - probably the user's Inbox. //Since there might not be any

              D Offline
              D Offline
              David Crow
              wrote on last edited by
              #8

              ranjjj wrote: also it displays only 1 read mail for 1 execution of thios code... Because there is no loop. How would you expect it to read more than once?


              Five birds are sitting on a fence. Three of them decide to fly off. How many are left?

              R 1 Reply Last reply
              0
              • R ranjjj

                i don't want a dialog box to be displayed.. logon_ui does that right?? and... the only problem now is.. it doesn't work out if the outlook window is not opened.. how to solve it..i tried using new sesion also..anddd..logon ui also.. it doesn't work! ranjani

                D Offline
                D Offline
                David Crow
                wrote on last edited by
                #9

                Then use:

                MAPILogon(0, "Microsoft Outlook Internet Settings", NULL, MAPI_NEW_SESSION, 0, &m_lhSession);


                Five birds are sitting on a fence. Three of them decide to fly off. How many are left?

                1 Reply Last reply
                0
                • D David Crow

                  char sMessageId[512],
                  sMessageSeed[512];
                  int nReturn;

                  sMessageId[0] = '\0';
                  sMessageSeed[0] = '\0';

                  nReturn = MAPIFindNext(m_lhSession, 0, NULL, sMessageSeed, MAPI_LONG_MSGID | MAPI_UNREAD_ONLY, 0, sMessageId);
                  if (SUCCESS_SUCCESS == nReturn)
                  {
                  do
                  {
                  // read the message

                      lstrcpy(sMessageSeed, sMessageId);        
                      nReturn = MAPIFindNext(m\_lhSession, 0, NULL, sMessageSeed, MAPI\_LONG\_MSGID | MAPI\_UNREAD\_ONLY, 0, sMessageId);
                  } while (SUCCESS\_SUCCESS == nReturn);
                  

                  }


                  Five birds are sitting on a fence. Three of them decide to fly off. How many are left?

                  R Offline
                  R Offline
                  ranjjj
                  wrote on last edited by
                  #10

                  even when i use this.. am not able to log o..when outlook window is not opened! ranjani

                  D 1 Reply Last reply
                  0
                  • D David Crow

                    ranjjj wrote: also it displays only 1 read mail for 1 execution of thios code... Because there is no loop. How would you expect it to read more than once?


                    Five birds are sitting on a fence. Three of them decide to fly off. How many are left?

                    R Offline
                    R Offline
                    ranjjj
                    wrote on last edited by
                    #11

                    am convinced with that... but... am not able to log on when outlook window is not opened.... where can the fault be?? kindly help me ..plzz ranjani

                    A 1 Reply Last reply
                    0
                    • R ranjjj

                      even when i use this.. am not able to log o..when outlook window is not opened! ranjani

                      D Offline
                      D Offline
                      David Crow
                      wrote on last edited by
                      #12

                      What is the return value of MAPILogon()?


                      Five birds are sitting on a fence. Three of them decide to fly off. How many are left?

                      R 1 Reply Last reply
                      0
                      • D David Crow

                        What is the return value of MAPILogon()?


                        Five birds are sitting on a fence. Three of them decide to fly off. How many are left?

                        R Offline
                        R Offline
                        ranjjj
                        wrote on last edited by
                        #13

                        the return value is MAPI_LOGON_FAILURE ..integer value is 3! ranjani

                        1 Reply Last reply
                        0
                        • R ranjjj

                          am convinced with that... but... am not able to log on when outlook window is not opened.... where can the fault be?? kindly help me ..plzz ranjani

                          A Offline
                          A Offline
                          Anonymous
                          wrote on last edited by
                          #14

                          Make outlook the default mail client (either from Internet Explorer -> Programs -> Email -> Microsoft Outlook, or from the registry HKLM\Software\Clients\Mail\(Default) = "Microsoft Outlook") and then try again

                          R 1 Reply Last reply
                          0
                          • A Anonymous

                            Make outlook the default mail client (either from Internet Explorer -> Programs -> Email -> Microsoft Outlook, or from the registry HKLM\Software\Clients\Mail\(Default) = "Microsoft Outlook") and then try again

                            R Offline
                            R Offline
                            ranjjj
                            wrote on last edited by
                            #15

                            thank you..will try and shall let u know ranjani

                            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