C++ and Outlook

I have a VBScript that can check Outlook (without Outlook being open) and return the number of unread messages in the inbox.  Is there a way to do this, from console, using C++? :)

Thanks,
Tony
LVL 1
fattumsdadAsked:
Who is Participating?
 
jkrConnect With a Mentor Commented:
Check out http://support.microsoft.com/default.aspx?scid=kb;en-us;171096 ("FILE: Simple MAPI Console Application")

This messaging application is a Simple MAPI client. It implements the following features:


Present the user with a menu
Logon to messaging system
Select a recipient/Get e-mail address
Enter e-mail address/Get recipient
Get details of recipient
Send mail message to recipient using default UI
Send mail message to recipient with no user interface
Send mail message with an attachment
Create a new message
List messages in the Inbox <------------------------------------
Read next unread message
Log off of the messaging system
Exit the client
Refresh the menu
0
 
AxterCommented:
>>Is there a way to do this, from console, using C++? :)

Yes.  You can use MAPI controls
0
 
fattumsdadAuthor Commented:
Axter,

Any examples you could share?  The only way I know how to use MAPI is with the MFC App Wizard...  I want to use Console only :)
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
AxterCommented:
0
 
jkrCommented:
>> Check out following links

Axter, *YOU* are starting that cr*p also?
0
 
fattumsdadAuthor Commented:
jkr,

I download the sample and the .exe works fine, but I get 7 errors when trying to compile the actual code...  can you help me with that?  It's a lot of code, that's why I ask....

0
 
AxterCommented:
>>Axter, *YOU* are starting that cr*p also?

I was going to copy and paste some code, but as usuall, you beat me to it.

Usually, when I post a link, I also post some code.  I was trying to find somde that was more closely related to "unread messages query".
0
 
jkrCommented:
>>Usually, when I post a link, I also post some code

Sorry, it's just that a lot of people start developing the habit of posting EE PAQ queries, maybe I am getting oversensitive to that :-(

fattumsdad,

What errors are you getting?
0
 
fattumsdadAuthor Commented:
Compiling source file(s)...
swap.cpp
In file included from swap.cpp:21:
swap.h:19:1: warning: "_WIN32" redefined
<built-in>:75:1: warning: this is the location of the previous definition
swap.h:35:19: mapix.h: No such file or directory
In file included from swap.cpp:21:
swap.h:56: warning: `class CApp' has virtual functions but non-virtual
destructor
swap.cpp: In member function `HRESULT CApp::cCaptureText(CHAR*, CHAR**)':
swap.cpp:195: error: `MAPIInitialize' undeclared (first use this function)
swap.cpp:195: error: (Each undeclared identifier is reported only once for each
function it appears in.)
swap.cpp:199: error: `MAPIAllocateBuffer' undeclared (first use this function)
swap.cpp:204: error: `MAPIUninitialize' undeclared (first use this function)
swap.cpp: In member function `HRESULT CApp::cCreateMessage(long unsigned int,
MapiMessage**, TCHAR**)':
swap.cpp:232: warning: initialization to non-pointer type `char' from NULL
swap.cpp:232: warning: argument to non-pointer type `char' from NULL
swap.cpp:255: error: `MAPIAllocateBuffer' undeclared (first use this function)
swap.cpp: In member function `HRESULT CApp::cFindMessageID(TCHAR*, long
unsigned int, TCHAR**)':
swap.cpp:373: error: `MAPIAllocateBuffer' undeclared (first use this function)
swap.cpp: In member function `HRESULT CApp::cSendAttachMail()':
swap.cpp:975: warning: initialization to non-pointer type `char' from NULL
swap.cpp:975: warning: argument to non-pointer type `char' from NULL
swap.cpp:971: warning: unused variable `ULONG cRecips'
swap.cpp: In member function `HRESULT CApp::cSendMessage(long unsigned int)':
swap.cpp:1110: warning: unused variable `ULONG cRecips'

Mail.exe - 7 error(s), 9 warning(s)

0
 
jkrCommented:
Is this the sample's code or yours? It seems that

#include <mapix.h>

is missing somewhere.
0
 
AxterCommented:
fattumsdad,

Do you have the latest SDK loaded on your computer.

If not, some of the MSDN code will not compile on your computer.

You can get the latest SDK free from MS.
0
 
fattumsdadAuthor Commented:
Axter,

I'm not using VC++, I'm using MinGW :)

jkr,

This is the samples code, I added #include <mapix.h> and I get "swap.h:35:19: mapix.h: No such file or directory".  I added it in swap.cpp, should I put it in the swap.h instead?
0
 
jkrCommented:
Are there any header files that come with MinGW that start with 'MAPI*'? If MAPIX.h is missing, that means real trouble...
0
 
fattumsdadAuthor Commented:
Found "mapi.h" and added #include <mapi.h> in both swap.cpp and swapmain.cpp, still the same 7 errors 9 warnings :(
0
 
jkrCommented:
Yes, but we'd need 'mapix.h' :-(

Can you see whether 'MAPIInitialize()' is in a different header file with MinGW?
0
 
fattumsdadAuthor Commented:
I'll check the header files and see if I can find that.  Also, I'll try running the code with VC++ when I get home :)
0
 
fattumsdadAuthor Commented:
jkr,

I just compiled the source with VC++ 6.0 and I'm still getting errors, I think there's something missing from the sample.  I'll just see what I can learn off of what's already there.  Thanks for your help :)
0
 
jkrCommented:
Compile fine here:

D:\tmp\Smplmapi>cl swap.cpp swpmain.cpp /link mapi32.lib
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8804 for 80x86
Copyright (C) Microsoft Corp 1984-1998. All rights reserved.

swap.cpp
swap.h(19) : warning C4005: '_WIN32' : macro redefinition
        unknown(0) : see previous definition of '_WIN32'
swpmain.cpp
swap.h(19) : warning C4005: '_WIN32' : macro redefinition
        unknown(0) : see previous definition of '_WIN32'
Generating Code...
Microsoft (R) Incremental Linker Version 6.00.8447
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.

/out:swap.exe
mapi32.lib
swap.obj
swpmain.obj
0
 
fattumsdadAuthor Commented:
I didn't do it from the command line...  I created a new project in VC++ and then added the source and header files.  Tried to build and got 3 errors.  I didn't even know that command line compiling was available in VC++ LOL not like I'd know how to use it anyway :)
0
 
jkrCommented:
Hmmm... What errors did you get, then?
0
 
fattumsdadAuthor Commented:
I'll have to get back to you on that one later this evening, I don't have VC++ here at work, only MinGW :(
0
 
jkrCommented:
No prob, take you time :o)
0
 
fattumsdadAuthor Commented:
jkr,

Here are the errors I get when trying to compile the sample with VC++:

Compiling...
swap.cpp
c:\swap.h(19) : warning C4005: '_WIN32' : macro redefinition
        unknown(0) : see previous definition of '_WIN32'
swpmain.cpp
c:\swap.h(19) : warning C4005: '_WIN32' : macro redefinition
        unknown(0) : see previous definition of '_WIN32'
Linking...
swap.obj : error LNK2001: unresolved external symbol _MAPIUninitialize@0
swap.obj : error LNK2001: unresolved external symbol _MAPIAllocateBuffer@8
swap.obj : error LNK2001: unresolved external symbol _MAPIInitialize@4
swap.obj : error LNK2001: unresolved external symbol _MAPIFreeBuffer@4
Debug/Test.exe : fatal error LNK1120: 4 unresolved externals
Error executing link.exe.

Test.exe - 5 error(s), 2 warning(s)

0
 
jkrCommented:
All you need to add is mapi32.lib, as in the above command line:

cl swap.cpp swpmain.cpp /link mapi32.lib

:o)

0
 
fattumsdadAuthor Commented:
Alright, I'll give it  a shot this evening and let you know how it goes.  Thanks :)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.