?
Solved

Emailing (alt. to MAPI)

Posted on 1998-10-06
11
Medium Priority
?
459 Views
Last Modified: 2012-05-04
I would like to send an email within my VC++ Win32 app.
It seems MAPI uses Exchange. Is there any classes out there
for emailing?
One which will let me attach a file, and use a proxy?
MAPI seems like it might work if Exchange is set up for
a proxy.. But I'd rather not have to worry about Exchange being set up, on top of my own app.
0
Comment
Question by:rderidder
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
  • +3
11 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 1174547
Simply use 'ShellExecute()' and supply 'mailto:<recipient>?<subject>' as the 'lpFile' parameter. This will start the default mailer application.
0
 

Author Comment

by:rderidder
ID: 1174548
I would like to send the email --within-- my C++ program.
Is there any classes or such which will let me do this without launching external programs?
I'm doubtfull, but just incase...

Otherwise, I could use the shellexec..or MAPI. Both of these require the default (or Exchange) mailing app. to be configured and setup properly.
I guess one difference between these two methods is that with MAPI I would have to ensure Exchange is runnable on every computer I run my app on, while shellexec just takes the default.


0
 
LVL 86

Expert Comment

by:jkr
ID: 1174549
Yes, that's the problem ... but MAPI also relies on a properly configured MS Exchange...
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:rderidder
ID: 1174550
The big problem with shellexecute is that the mailing app is executed, and then user interaction is needed. MAPI allows me to send the message automatically.
The app I am making is automated. Emails are sent out without needing user interaction.

i.e: When you register over the net, and the reg. number is sent automatically via email after processing (automatically) to you..How was that email sent do you suppose?
0
 
LVL 5

Expert Comment

by:yonat
ID: 1174551
I remember there are SMTP and POP3 classes somewhere in www.codeguru.com - take a look.
0
 
LVL 1

Expert Comment

by:Grailman
ID: 1174552
This should do it all for you:
void OnSend()
{
LHANDLE lhSession = 0;
ULONG ul = 0;

////////////////////////////////////////////////////////
// Compose message
CString csSubject = "Email Test";
CString csText = "\nIt's SO great to be programming today!\n"
"Thank you for your time!\n";

////////////////////////////////////////////////////////
// Load the DLL

HINSTANCE hInstMail = ::LoadLibraryA("MAPI32.DLL");
if(hInstMail == NULL)
{
AfxMessageBox(AFX_IDP_FAILED_MAPI_LOAD);
return;
}
ASSERT(hInstMail != NULL);

/* Logon (and Logoff) only needed if a session is not started or
you want to send from a diffrent profile

////////////////////////////////////////////////////////
// Create function pointer to 'MAPILogon' & Logon

ULONG (PASCAL *lpfnLogon)(ULONG, LPTSTR, LPTSTR, FLAGS, ULONG, LPLHANDLE);
(FARPROC &)lpfnLogon = GetProcAddress(hInstMail, "MAPILogon");

lpfnLogon(NULL, "Session", "Password", 0, 0, &lhSession);

*/
////////////////////////////////////////////////////////
// Create function pointer to 'MAPISendMail'

ULONG (PASCAL *lpfnSendMail)(ULONG, ULONG, MapiMessage *, FLAGS, ULONG);
(FARPROC &)lpfnSendMail = GetProcAddress(hInstMail, "MAPISendMail");

if(lpfnSendMail == NULL)
{
AfxMessageBox(AFX_IDP_INVALID_MAPI_DLL);
return;
}


////////////////////////////////////////////////////////
// Set up MAPI structs

// Who's sending this email???
MapiRecipDesc MapiFrom;
memset(&MapiFrom, 0, sizeof(MapiFrom));
MapiFrom.ulRecipClass = MAPI_ORIG;
MapiFrom.lpszName = "Big Cheese email sender";
MapiFrom.lpszAddress = "SMTP:BigGuy@myprovider.com";

// Who gets this email???
MapiRecipDesc MapiTo[2]; // Array of recipiants
memset(&MapiTo[0], 0, sizeof(MapiTo[0]));
MapiTo[0].ulRecipClass = MAPI_TO;
MapiTo[0].lpszName = "Big Cheese email receiver #1";
MapiTo[0].lpszAddress = "SMTP:otherguy@hisprovider.com";

// Who else gets this email???
memset(&MapiTo[1], 0, sizeof(MapiTo[1]));
MapiTo[1].ulRecipClass = MAPI_TO;
MapiTo[1].lpszName = "Big Cheese email receiver #2";
MapiTo[1].lpszAddress = "SMTP:someguy@anotherprovider.com";


////////////////////////////////////////////////////////
// Create struct for MAPI to process

MapiMessage Email;
memset(&Email, 0, sizeof(Email));

Email.lpszSubject = csSubject.GetBuffer(csSubject.GetLength());
Email.lpszNoteText = csText.GetBuffer(csText.GetLength());
Email.lpOriginator = &MapiFrom;
Email.lpRecips = MapiTo;      
Email.nRecipCount = 2;      

// Email.flFlags // various
// Email.lpFiles // pointer to 'MapiFileDesc' struct for attachments
// Email.nFileCount


////////////////////////////////////////////////////////
// Call MAPISendMail

ul = lpfnSendMail(lhSession, 0, &Email, 0, 0);
if(ul == SUCCESS_SUCCESS)
AfxMessageBox("Mail Sent! We're happy!");

/* Logoff (and Logon) only needed if a session is not started or
you want to send from a diffrent profile

////////////////////////////////////////////////////////
// Logoff

// Create function pointer to 'MAPILogoff'
ULONG (PASCAL *lpfnLogoff)(LHANDLE, ULONG, FLAGS, ULONG);
(FARPROC &)lpfnLogoff = GetProcAddress(hInstMail, "MAPILogoff");

ul = lpfnLogoff(lhSession, 0, 0, 0);

*/
if(hInstMail != NULL)
::FreeLibrary(hInstMail);
}



0
 

Author Comment

by:rderidder
ID: 1174553
That looks almost exactly like what I've got. I would like --alternatives to MAPI--.
ie: a SMTP class.

Then maybe I would not be dependent on an Exchange Inbox Profile?

There is one at codeguru, but it doesn't take attachments as yet.

Thanks though..
0
 
LVL 8

Expert Comment

by:MaDdUCK
ID: 1174554
I would need this info too...
0
 
LVL 23

Expert Comment

by:chensu
ID: 1174555
E-Mail file attachment using MIME
http://www.codeguru.com/internet/mimemfc.shtml
0
 

Author Comment

by:rderidder
ID: 1174556
Great stuff! thanks!...

How about I accept an answer from ya chensu?
(Although Wes Clyburn was key as well!)
0
 
LVL 23

Accepted Solution

by:
chensu earned 150 total points
ID: 1174557
Thank you.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
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.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
Suggested Courses

741 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