Modem Communication & POP

In C++ how do I communicate with modem and create my own e-mail programme using POP (Post Office Protocol)?
smsaleemAsked:
Who is Participating?
 
AlexVirochovskyCommented:
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
   );




HRESULT
CEmailApp::SendMail ()
{
HRESULT hRes = S_OK;
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"));
hRes = MAPI_E_FAILURE;
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)
Alex
0
 
smsaleemAuthor Commented:
I would be glad if the code is meant for DOS environemtn and not for Windows.
0
 
AlexVirochovskyCommented:
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!).
0
 
smsaleemAuthor Commented:
Thank you that's what I suspected!
My e-mail is smsaleem@isb.comsats.net.pk
0
 
AlexVirochovskyCommented:
OK, i am very glad to help you.
Don't forget evaluate the reply.
Alex
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.