Exchange mails (sending + receiving) on not-logged-on account, VC++ 6.0

Posted on 2006-04-12
Last Modified: 2010-04-01
I need to log on to an Exchange server to check my Inbox, copy the content of the mails to a text file and move the mails into an archive folder. Also I must be able to send mails.

Big Problem: The exchange mail account belongs to another windows user account.

I am Administrator, have full rights and would (if needed) hardcode all login / password stuff for the mail account ("tsdp"). But I haven't managed yet, I guess i must first impersonate myself before I can operate. Or ? I have no exchange password, only the windows user account password, but did never manage to come into the mail account.

Do I have to add an additional mail profile in order that it works ?

I use Visual C++ 6.0 / Visual Basic 6.0, what technique would allow me the most technically-up-to-date stuff and flexibility ? (no, I mean  not ".NET" and not web service stuff like ADO)  CDO 1.2.1 ? Or some MAPI functions ? I need some code snippets that help me perform this task.
Question by:PC-Alex
    LVL 86

    Expert Comment

    You should be able to specify any arbitrary Exchange user name when calling 'MAPILogon()' or 'MAPILogonEx()' independent from the Windows account you're using. See also the samples at and ("Sending and receiving e-mails from your program") in particular.
    LVL 1

    Author Comment

    Thanks for the tips, jkr, codeproject was also my first source to examine.

    I just found out that the problem was due to missing rights on the exchange account: I am member of the Admin group, I am entitled to "send as" on this account, I had an additional mail profile for this box ... but that was not enough.

    I had to make the check box in Active Directory Users und Computers, "View" / "Advanced Features", to be able to see "Exchange Advanced", where I can give me the "Permissions for tsdp". That was it.

    I have documented the full details on (in german)

    Accepted Solution

    PAQed with points refunded (500)

    Community Support Moderator

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Join & Write a Comment

    When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
      Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
    The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
    The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now