I need to build a Windows program with Visual C++ that sends an SMTP email when an alarm condition occurs. I will be reading data out of several PLCs (automation controllers) with the help of active-x controls purchased earlier for other projects.

New to Visual C++, (I'm mostly an old VB6 guy) I love the terse and powerful syntax of C, so I will be migrating to VC++ as time allows. C# bites, I'd rather stop programming than use that...

I have some code for a console application that works OK, so if no one has an example of SMTP email using C++, maybe someone has a way to run a separate command line exe from within a Windoze Forms program.

I have done some lengthy reading in winsock2.h but have to admit being a both overwhelmed (and ignorant) about how to interpret it to create code that uses it.

I was further confused when I placed the statement

include <winsock2.h>

in my program; I get a jillion errors about redefinitions that refer to ws2def.h

Well... I'm not sure how ws2def.h got in the mix to start with, possibly during the selection of project type... I dimly recall check boxes referring to things that may have included winsock.

All of that to say just this: I need some help from someone using Visual C++ 2010 to get me over the hump for SMTP email. I've put in lots of hours learning how to work with text files, forms, etc. and am getting encouraged (finally) about being able to produce more useful programs. Right now though, I'm just as stuck as I was two weeks ago... up to the axles!

Thank you for your thoughtful consideration of this; there is precious little on the subject other than "BUY MY EMAIL CONTROL FOR ONLY $99.99".

Well, I had found a link for a console program that (if I understand correctly) used SMTP commands sent with telnet. So far I'm only able to send an email without a subject line and without any message because I haven't figured out how to construct the "message file" that the program uses. But I'm reading a lot about "SMTP Commands" from some searches, and I'm sure I'll get there sooner or later. I was kind of hoping someone other than flukebob would answer flukebob, and give him/me a few different perspectives of how to go at the problem. I'll keep looking for some more C++ nuts and bolts for telnetting, and also look for another angle: I could just compile the console program, write a file with the correct format that the console program needs, (easy, thank God) and call the console program from within my windows program. -somehow- HINT HINT maybe someone could please give me a keyword to research right off the top of their head, and save me HOURS of time?

OK, this thread is solved. It's evidently too lengthy and I've not been specific because I DIDN'T HAVE ANY IDEA WHAT TO DO AT THE TIME but now I do. OK, so I'll post a new thread that asks how to call an exe from within a C++ WINDOWS FORMS program. But I'll ask only if I can't find what I need. For the purposes of some poor thing that has to have an answer other than me,

http://www.codeguru.com/forum/showthread.php?t=372474

has several avenues to chase down. I figure if a person wants to stay inside "supported" MS code later on, they could just use the console program by Masur and get on with life by calling it from a .net program. Otherwise, I still don't know.
BUT I suggest to myself (and anyone else with the same programming problem) to check out the acronym SMTP on MSDN for a more elegant solution.

If I find something better later on, I'll post it on Daniweb for other unfortunates.

I need to build a Windows program with Visual C++ that sends an SMTP email when an alarm condition occurs. I will be reading data out of several PLCs (automation controllers) with the help of active-x controls purchased earlier for other projects.

New to Visual C++, (I'm mostly an old VB6 guy) I love the terse and powerful syntax of C, so I will be migrating to VC++ as time allows. C# bites, I'd rather stop programming than use that...

I have some code for a console application that works OK, so if no one has an example of SMTP email using C++, maybe someone has a way to run a separate command line exe from within a Windoze Forms program.

I have done some lengthy reading in winsock2.h but have to admit being a both overwhelmed (and ignorant) about how to interpret it to create code that uses it.

I was further confused when I placed the statement

include <winsock2.h>

in my program; I get a jillion errors about redefinitions that refer to ws2def.h

Well... I'm not sure how ws2def.h got in the mix to start with, possibly during the selection of project type... I dimly recall check boxes referring to things that may have included winsock.

All of that to say just this: I need some help from someone using Visual C++ 2010 to get me over the hump for SMTP email. I've put in lots of hours learning how to work with text files, forms, etc. and am getting encouraged (finally) about being able to produce more useful programs. Right now though, I'm just as stuck as I was two weeks ago... up to the axles!

Thank you for your thoughtful consideration of this; there is precious little on the subject other than "BUY MY EMAIL CONTROL FOR ONLY $99.99".

This question has already been answered. Start a new discussion instead.