sending e-mail from c++ code
I am making a console app that needs to send e-mail when asked so.How could i do that ? Though i tried this link it was not successful, b开发者_如何学编程ecause you need additional software for it. AND there is a delay of about 10 minutes when i actually get the email.what could be the problem ?
This is the dialog box displayed when you run the first code
Is there any other way out ?
Are there any links that explain sending e-mail from c++ program step by step explaining the function used in the code.
Give VMime a try!
(Sending mail is not a language built-in feature, you will have to use some sort of library.)
If you just want to open a mail window in your default mail agent, use ShellExecute
:
ShellExecute(
NULL,
NULL,
TEXT("mailto:foo@example.com"),
NULL,
NULL,
SW_SHOWNORMAL);
Additionally: connected topic: C++ SMTP Example.
For sending eMail you can open a tcp network socket to the mailserver of the recipient, e.g. smtpmail.example.com, port 25.
For details to Windows sockets programming see http://www.snible.org/winsock/ or other tutorials.
Then write text to that socket according to the SMTP protocol:
HELO mymachine_ipaddress_or_dnsname
MAIL FROM:<me@somewhere.net>
DATA
From: <me@somewhere.net>
To: <you@example.com>
Subject: Test message
Hello, greetings.
.
QUIT
Then close socket. In fact, there is no built-in sender authentication in SMTP...
libCurl is a highly portable C/C++ networking library that supports SMTP. There is a sample on their site.
you can use CDO for doing this. I think it bypases the outlook object model. So you wont get this warning dialogue also.
精彩评论