I am trying to send email using Indy 10.5.7 on C++ Builder XE but I get Host not found error. I added TIdSMTP, TIdSSLIOHandlerSocketOpenSSL and TIdMessage components. I set the host to smtp.office365.com, the port to 587 and UseTLS to utUseExplicitTLS. The username and password are set for the email address of the account I need to connect with.
I am trying to send the email using :
IdMessage1->From->Name = Name->Text;
IdMessage1->From->Address = EmailAddress->Text;
IdMessage1->Body = Msg->Lines;
try
{
IdSMTP1->Connect(1000);
try
{
IdSMTP1->Send(IdMessage1);
}
__finally
{
IdSMTP1->Disconnect();
}
}
catch (const Exception &E)
{
MessageBox(NULL, E.Message.c_str(), L"Error", MB_OK | MB_ICONERROR);
}