Reputation: 23256
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, because 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.
Upvotes: 1
Views: 5183
Reputation: 3909
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:<[email protected]>
DATA
From: <[email protected]>
To: <[email protected]>
Subject: Test message
Hello, greetings.
.
QUIT
Then close socket. In fact, there is no built-in sender authentication in SMTP...
Upvotes: 2
Reputation: 7744
If you just want to open a mail window in your default mail agent, use ShellExecute
:
ShellExecute(
NULL,
NULL,
TEXT("mailto:[email protected]"),
NULL,
NULL,
SW_SHOWNORMAL);
Additionally: connected topic: C++ SMTP Example.
Upvotes: 3
Reputation: 1074
you can use CDO for doing this. I think it bypases the outlook object model. So you wont get this warning dialogue also.
Upvotes: 0
Reputation: 27174
libCurl is a highly portable C/C++ networking library that supports SMTP. There is a sample on their site.
Upvotes: 1