|
-
September 18th, 2010, 08:16 AM
#1
My program doesn't work! Please help.
Hello everyone. I made this little program for sending mail, everything looks fine (for me), got no errors, debugging without a problem. Only problem is that its not working. My program doesn't send mail. Can you please tell me why? Thanks.
Code:
// msdnproba2.cpp : main project file.
#include "stdafx.h"
#include <Windows.h>
#include <iostream>
#include <string>
using namespace System;
using namespace System::Net::Mail;
using namespace System::Net;
using namespace std;
int main(array<System::String ^> ^args)
{
cout << "Sending mail..."<< endl;
char f;
cin >> f;
return 0;
}
static void Mail_test1( String^ server, int port )
{
String^ to = L"[email protected]";
String^ from = L"[email protected]";
String^ subject = L"This is subject!";
String^ body = L"Hello! This is a test.";
MailMessage^ message = gcnew MailMessage( from,to,subject,body );
SmtpClient^ client = gcnew SmtpClient( "smtp.mail.yahoo.com , 465" );
client->Credentials = gcnew NetworkCredential("[email protected]", "mypassword", "smtp.mail.yahoo.com");
client->UseDefaultCredentials = false;
ServicePoint^ p = client->ServicePoint;
Console::WriteLine( L"Connection lease timeout: {0}", p->ConnectionLeaseTimeout );
client->Send( message );
client->~SmtpClient();
}
-
September 18th, 2010, 08:37 AM
#2
Re: My program doesn't work! Please help.
YOU don't need your input "f", why is it there ?
You didn't call your function, only input your nonsense irrelevant f
-
September 18th, 2010, 09:37 AM
#3
Re: My program doesn't work! Please help.
Oh God. I didn't program for a WHILEEE. I forgot everything. 
I changed the problem now, but still my program doesn't work. Any clue?
Code:
// test3.cpp : main project file.
#include "stdafx.h"
#include <Windows.h>
#include <iostream>
#include <string>
using namespace System;
using namespace System::Net::Mail;
using namespace System::Net;
using namespace std;
static void mailtest1 ( String^ server, int port )
{
String^ to = L"[email protected]";
String^ from = L"[email protected]";
String^ subject = L"This is subject!";
String^ body = L"Hello! This is a test.";
MailMessage^ message = gcnew MailMessage( from,to,subject,body );
SmtpClient^ client = gcnew SmtpClient( "smtp.mail.yahoo.com , 465" );
client->Credentials = gcnew NetworkCredential("[email protected]", "password", "smtp.mail.yahoo.com");
client->UseDefaultCredentials = false;
ServicePoint^ p = client->ServicePoint;
Console::WriteLine( L"Connection lease timeout: {0}", p->ConnectionLeaseTimeout );
client->Send( message );
client->~SmtpClient();
}
int main(array<System::String ^> ^args)
{
mailtest1;
return 0;
}
-
September 18th, 2010, 11:52 AM
#4
Re: My program doesn't work! Please help.
You may want to ask in one of the .net forums.
-
September 21st, 2010, 08:57 AM
#5
Re: My program doesn't work! Please help.
Problem 1:
Code:
mailtest1 ( String^ server, int port )
you never use server and port, why don't you get rid of them?
Problem 2
Code:
int main(array<System::String ^> ^args)
{
mailtest1;
return 0;
}
This shouldn't compile. You should call mailtest1() passing the right arguments, or if you get rid of the server and port parameters, without any arguments.
Code:
int main(array<System::String ^> ^args)
{
mailtest1();
return 0;
}
-
September 25th, 2010, 02:26 PM
#6
Re: My program doesn't work! Please help.
I fixed that. Thanks for the reply , but my mail still isn't sent.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|