How to send email?

Using C or C++.
   I am having a dificulty sending email. Please direct me in solving this problem. No MFC ( :

any of your tips will be appreciated.
thak you.
VirtualRealityAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

vachoohoCommented:
ShellExecute("mailto:me@mysite.com?subject=Something")

or MAPISendMail()

want sample code?

0
vachoohoCommented:
Here is some code for MAPI send mail

/////////////////////////////////////////////////////////////////////////////////////////////
// MAILING SUPPORT
/////////////////////////////////////////////////////////////////////////////////////////////

AFX_STATIC_DATA BOOL _afxIsMailAvail = (BOOL)-1;    // start out not determined

class _AFX_MAIL_STATE : public CNoTrackObject
{
public:
      HINSTANCE m_hInstMail;      // handle to MAPI32.DLL
      virtual ~_AFX_MAIL_STATE();
};

_AFX_MAIL_STATE::~_AFX_MAIL_STATE()
{
      if (m_hInstMail != NULL)
            ::FreeLibrary(m_hInstMail);
}

static _AFX_MAIL_STATE _afxMailState;

void SendViaMail(LPCTSTR szFileName, CWnd * pWnd)
{
      ASSERT(_afxIsMailAvail);   // update handler always gets called first
      ASSERT(pWnd);

      CWaitCursor wait;

      _AFX_MAIL_STATE * pMailState = &_afxMailState;
      if(pMailState->m_hInstMail == NULL)
            pMailState->m_hInstMail = ::LoadLibraryA("MAPI32.DLL");

      if(pMailState->m_hInstMail == NULL)
      {
            pWnd->MessageBox(MESSAGE_MAPILOADFAILED, MESSAGE_MAPICAPTION);
            return;
      }
      ASSERT(pMailState->m_hInstMail != NULL);

      ULONG (PASCAL *lpfnSendMail)(ULONG, ULONG, MapiMessage*, FLAGS, ULONG);
      (FARPROC&)lpfnSendMail = ::GetProcAddress(pMailState->m_hInstMail, "MAPISendMail");
      if(lpfnSendMail == NULL)
      {
            pWnd->MessageBox(MESSAGE_MAPINOTFOUND, MESSAGE_MAPICAPTION);
            return;
      }
      ASSERT(lpfnSendMail != NULL);

      // build file title
      CString strTitle;
      {
            TCHAR drive[_MAX_DRIVE];
            TCHAR dir[_MAX_DIR];
            TCHAR fname[_MAX_FNAME];
            TCHAR ext[_MAX_EXT];

            ::_tsplitpath(szFileName, drive, dir, fname, ext);
            
            CString strFName(fname);
            if((strFName.GetLength() > 0) && (strFName[strFName.GetLength() - 1] == '.'))
                        strFName = strFName.Left(strFName.GetLength() - 1);

            // ???? ough !!! UNICODE ???
            strTitle.Format(_T("%s%s"), strFName, ext);
      }
      
      // prepare the file description (for the attachment)
      MapiFileDesc fileDesc;
      memset(&fileDesc, 0, sizeof(fileDesc));
      fileDesc.nPosition = (ULONG)-1;
      fileDesc.lpszPathName = (char *)szFileName;
      fileDesc.lpszFileName = (LPTSTR)(LPCTSTR)strTitle;

      // prepare the message (empty with 1 attachment)
      MapiMessage message;
      memset(&message, 0, sizeof(message));
      message.nFileCount = 1;
      message.lpFiles = &fileDesc;

      // prepare for modal dialog box
      ::AfxGetApp()->EnableModeless(FALSE);
      
      HWND hWndTop;
      
      //CWnd * pParentWnd = pWnd->GetSafeOwner(NULL, &hWndTop);
      CWnd * pParentWnd = ::AfxGetMainWnd();
      hWndTop = pWnd->m_hWnd;

      // some extra precautions are required to use MAPISendMail as it
      // tends to enable the parent window in between dialogs (after
      // the login dialog, but before the send note dialog).
      pParentWnd->SetCapture();
      
      ::SetFocus(NULL);
      
      pParentWnd->m_nFlags |= WF_STAYDISABLED;

      int nError = lpfnSendMail(0, (ULONG)pParentWnd->GetSafeHwnd(), &message, MAPI_LOGON_UI|MAPI_DIALOG, 0);

      // after returning from the MAPISendMail call, the window must
      // be re-enabled and focus returned to the frame to undo the workaround
      // done before the MAPI call.
      ::ReleaseCapture();
      
      pParentWnd->m_nFlags &= ~WF_STAYDISABLED;

      pParentWnd->EnableWindow(TRUE);
      
      ::SetActiveWindow(NULL);
      
      pParentWnd->SetActiveWindow();
      pParentWnd->SetFocus();

      if(hWndTop != NULL)
            ::EnableWindow(hWndTop, TRUE);
      
      ::AfxGetApp()->EnableModeless(TRUE);

      if(nError != SUCCESS_SUCCESS && nError != MAPI_USER_ABORT && nError != MAPI_E_LOGIN_FAILURE)
            pWnd->MessageBox(MESSAGE_MAPISENDFAILED, MESSAGE_MAPICAPTION);
}

BOOL MAPIEnabled()
{
      if (_afxIsMailAvail == (BOOL)-1)
      {
            _afxIsMailAvail = (::GetProfileInt(_T("MAIL"), _T("MAPI"), 0) != 0) && (::SearchPath(NULL, _T("MAPI32.DLL"), NULL, 0, NULL, NULL) != 0);
      }

      return _afxIsMailAvail;
}


Although here I use some MFC classes you will be able easy get rid of them and replace with API/your app functions.

Hope this helps

0
chensuCommented:
You'd better post the question to the Windows programming topic area since you are not using MFC.
0
ValentinCommented:
if you want i can send to you a class of a LinkControl
it enable to put into your dialog a hyperlink control like
mailto:dragon.flamingo.ro
or
http://www.flamingo.ro
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.