harkoslav
September 18th, 2010, 08:16 AM
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.
// 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"mymail1@yahoo.com";
String^ from = L"mymail2@yahoo.com";
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("mymail2@yahoo.com", "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();
}
// 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"mymail1@yahoo.com";
String^ from = L"mymail2@yahoo.com";
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("mymail2@yahoo.com", "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();
}