• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 241
  • Last Modified:

Modem Communication & POP

In C++ how do I communicate with modem and create my own e-mail programme using POP (Post Office Protocol)?
  • 3
  • 2
1 Solution
Best way : use MAPI Api
next is simple example of sending
message in Mapi.
Send EMail
In one of the function, you need to get pointers to the MAPI functions. e.g.

HINSTANCE hlibMAPI = LoadLibrary (MAPI32.DLL); // assuming you are using Win32 environment.

m_MAPILogon = (LPMAPILOGON) GetProcAddress (hlibMAPI, "MAPILogon");
m_MAPILogOff = (LPMAPILOGOFF) GetProcAddress (hlibMAPI, "MAPILogoff");
m_MAPISendMail = (LPMAPISENDMAIL) GetProcAddress (hlibMAPI, "MAPISendMail");

Then you need to logon to MAPI.... using logon function.

LPSTR lpszProfileName;
LPSTR lpszPassword;

HRESULT hRes = m_MAPILogon (
0L, // Handle to parent window or 0.
lpszProfileName, // Default profile name to use for MAPI session.
lpszPassword, // User password for MAPI session.
flags, // Various session settings
ulReserved, // Reserved.  Must be 0L.
&m_lhSession // Return handle to MAPI Session

CEmailApp::SendMail ()
FLAGS flags;
ULONG ulReserved = 0L;
ULONG cRecips = 0L;
MapiRecipDesc recips;
MapiMessage message;

ZeroMemory (&message, sizeof (MapiMessage));
ZeroMemory (&recips, sizeof (MapiRecipDesc));

if (m_lhSession != NULL) {
// recipient description.
recips.ulReserved = ulReserved;
recips.ulRecipClass = MAPI_TO;
recips.lpszName = _T ("Naveen");
recips.lpszAddress = _T ("SMTP:naveen@krishna.mv.com");

// Message description.
message.lpszSubject = (LPSTR) "My Subject";
message.lpszNoteText = (LPSTR) "Testing MAPI application";
message.nRecipCount = 1L;
message.lpOriginator = NULL;
message.nFileCount = 0L;
message.ulReserved = ulReserved;
message.lpRecips = &recips;

flags = ~MAPI_DIALOG;

hRes = m_MAPISendMail (m_lhSession, 0L, &message, flags, ulReserved);
if (hRes != SUCCESS_SUCCESS) {
SetErrorMessage (hRes);
else {
TRACE (_T ("There is no active MAPI Session!\n"));
SetErrorMessage (hRes);

FreeBuffer (&message);
FreeBuffer (&recips);

return hRes;

At the end, log off from MAPI

m_MAPILogOff (m_lhSession, 0L, 0L, 0L);

If you want, i can send you full
example (write you EMail)
smsaleemAuthor Commented:
I would be glad if the code is meant for DOS environemtn and not for Windows.
O, Dos! You must write about it
in text of Question!
See http://www.marshallsoft.com/
for Dos Libraries for POP3 protocol
(but not free!).
smsaleemAuthor Commented:
Thank you that's what I suspected!
My e-mail is smsaleem@isb.comsats.net.pk
OK, i am very glad to help you.
Don't forget evaluate the reply.
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.

Join & Write a Comment

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now