How to email a simple plain text on windows form application

Post your questions regarding programming in C++ in here.
22 posts Page 1 of 3
Contributors
User avatar
emreozpalamutcu
New Member
New Member
Posts: 15
Joined: Wed Jun 22, 2011 6:43 pm

I using visual studio 2010 C++ Windows form application with net framework 4 and I want to send a simple text email without any login requirement. The code will read the text in richtextbox1 and email it to my email. which is custom email for example : example@custom.com
User avatar
MrAksel
C# Coder
C# Coder
Posts: 1758
Joined: Fri Mar 26, 2010 12:27 pm

I know how to do it in VB.NET and eventually C#, but not C++ :(
LMAOSHMSFOAIDMT
Laughing my a** of so hard my sombrero fell off and I dropped my taco lmao;


Over 30 projects with source code!
Please give reputation to helpful members!

Image
Image
User avatar
emreozpalamutcu
New Member
New Member
Posts: 15
Joined: Wed Jun 22, 2011 6:43 pm

Can you do a search for me, I'm doing a search for 13 hours, did you use SMTP to send email?
User avatar
mandai
Coding God
Coding God
Posts: 2585
Joined: Mon Apr 26, 2010 6:51 pm

SMTP is the simplest way of sending mail. You can use this:
Code: Select all
using namespace System::Net::Mail;
Code: Select all
	private: System::Void btnSend_Click(System::Object^  sender, System::EventArgs^  e) {

            SmtpClient^ sc = gcnew SmtpClient();
            sc->Host = "localhost";
            sc->Port = 25;

            MailMessage^ mm = gcnew MailMessage();
            mm->From = gcnew MailAddress("user@source");
            mm->To->Add(gcnew MailAddress("example@custom.com"));

            mm->Body = richTextBox1->Text;

            sc->Send(mm);
			 }
User avatar
emreozpalamutcu
New Member
New Member
Posts: 15
Joined: Wed Jun 22, 2011 6:43 pm

Hi again your code compiles fin however when i click the button to send it i get this error: An unhandled exception of type 'System.Net.Mail.SmtpException' occurred in System.dll
User avatar
Snyper345
VIP - Donator
VIP - Donator
Posts: 471
Joined: Mon Nov 01, 2010 1:53 am

emreozpalamutcu wrote:
Hi again your code compiles fin however when i click the button to send it i get this error: An unhandled exception of type 'System.Net.Mail.SmtpException' occurred in System.dll
show him/us your code so we can see if you have done something wrong
Image
Image
User avatar
emreozpalamutcu
New Member
New Member
Posts: 15
Joined: Wed Jun 22, 2011 6:43 pm

it's the code above the one mandai posted
User avatar
Snyper345
VIP - Donator
VIP - Donator
Posts: 471
Joined: Mon Nov 01, 2010 1:53 am

emreozpalamutcu wrote:
it's the code above the one mandai posted
well im sure youll have to change the host etc.
also check if por 25 is open @ http://www.yougetsignal.com/tools/open-ports/ but im sure it doesnt need to be opened...
Image
Image
User avatar
emreozpalamutcu
New Member
New Member
Posts: 15
Joined: Wed Jun 22, 2011 6:43 pm

I know that SMTP is port 25 it says it on the website to and it's closed from my ip and i don't know how to open it and it might be the host any suggestions
User avatar
emreozpalamutcu
New Member
New Member
Posts: 15
Joined: Wed Jun 22, 2011 6:43 pm

I just realised i can right anything on the ip bit and i wrote local host with port 25 and it's open any other ideas.
22 posts Page 1 of 3
Return to “General coding help”