Sending mail in C/C++ in unix server

Hi Frnds,

I have a task in my project wherein i have to send out a mail from my C++ code.With some file attachements.Please help me in this.

At a higher level wat i can tell is my code generated 3 csv file and i have to send these files as attachement.

My code is executed in unix server.So please suggest me how to do this.

If possible also please tell me how to do this in windows also.

Thanks in advance please reply asap.

Use fork()/exec()/wait() or system() to run a shell script to wrap the email client.

Use MAPI2.

popen() using sendmail directly might be an option to.

Can u please tell more details i am somewhat naive user

But you can program in C & C++?

On UNIX, I was suggesting you write a script to wrap the email functionality so this can be customized without recompilation, then call this from the C++ program.

On Windows you should use the MAPI 2 interface, this provides an COM/OLE interface to a mail provider and supports adding attachments as part of the API.

I'm in agreement with the other folks in this thread that
using established systems mail tools to accomplish what you
are doing is simpler.

If you really need to do the entire project in C you could take
a look at libesmtp -- libESMTP - A Library for Posting Electronic Mail
Or possibly the c-client library bundled with UW imap: UW IMAP software--IMAP Information Center.

popen is a very simple function to use. It allows you to open a system command as a FILE stream, for reading or writing. To send an email, you will want to open a stream for writing so you can "print" the contents of the email into the function:

You would, of course, want to add some error checking to this.