Te mando este codigo que funciona :
Código Delphi
[-]
bool __fastcall TFrmMail::EnviaMail()
Mensaje = new TIdMessage(NULL);
Mensaje->Clear();
Mensaje->ContentType = "multipart/mixed";
Mensaje->From->Name = FromName;
Mensaje->From->Address = FromAddress;
Mensaje->Subject = Subject;
Ini= new TIniFile( ModuloDeDatos->DirExe + "CorreoAdmin.ini");
Host=Ini->ReadString("Correo","Host","");
Port=Ini->ReadInteger("Correo","Port",26);
UserID=Ini->ReadString("Correo","UserID","");
FromAddress=Ini->ReadString("Correo","FromAddress","");
FromName=Ini->ReadString("Correo","FromName","IDEA Sistemas Activaciones");
PlantillaHTML=Ini->ReadString("Correo","PlantillaHTML","");
Logo=Ini->ReadString("Correo","Logo","");
TextoAdicional=Ini->ReadString("Correo","TextoAdicional","");
UsaSSL=Ini->ReadBool("Correo","UsaSSL",false);
UsaSTARTTLS=Ini->ReadBool("Correo","UsaSTARTTLS",false);
delete Ini;
CorreoDestino="juan.novelo@hotmail.com";
CC = "juan.novelo@ideasistemas.mx";
SMTP->Username = UserID;
SMTP->Password = Pass;
BodyIndyText = new TIdText(Mensaje->MessageParts,NULL);
BodyIndyText->ContentType="text/plain";
BodyIndyText->Body->Text="";
Temp=EdtBody->Text;
EdtBody->Text=EdtTextAdicional->Text + "
" + EdtBody->Text;
BodyIndyHtml = new TIdText(Mensaje->MessageParts,EdtBody->Lines);
BodyIndyHtml->ContentType="text/html";
BodyIndyHtml->Body->Clear();
BodyIndyHtml->Body->Add(EdtBody->Text);
if(FileExists(Logo))
while(i< ListaCC->Count)
i=0;
while(i< ListaBCC->Count)
i=0;
while(i< ListaPara->Count)
if(CmbAttachs->Properties->Items->Count > 0 && FileExists(CmbAttachs->Properties->Items->Strings[0]))
IndyAttach1 = new TIdAttachment( Mensaje->MessageParts, CmbAttachs->Properties->Items->Strings[0] );
if(CmbAttachs->Properties->Items->Count > 1 && FileExists(CmbAttachs->Properties->Items->Strings[1]))
IndyAttach2 = new TIdAttachment( Mensaje->MessageParts, CmbAttachs->Properties->Items->Strings[1] );
if(CmbAttachs->Properties->Items->Count > 2 && FileExists(CmbAttachs->Properties->Items->Strings[2]))
IndyAttach3 = new TIdAttachment( Mensaje->MessageParts, CmbAttachs->Properties->Items->Strings[2] );
if(CmbAttachs->Properties->Items->Count > 3 && FileExists(CmbAttachs->Properties->Items->Strings[3]))
IndyAttach4 = new TIdAttachment( Mensaje->MessageParts, CmbAttachs->Properties->Items->Strings[3] );
while(Intento < 2)
if(SMTP->Connected())
Intento=2;
PuedeCerrar=true;
}
catch(Exception &e)
else
Intento++;
PuedeCerrar=false;
}
}
__finally
}
}
return Que;
}