The email app is a sample app which is part of the 100 cross platform samples set. It was mainly tested on Windows so there may need to be small tweaks made for it to run smoothly on the other platform. It uses TFDMemTable to store settings and the mail itself. It only took 585 lines of code to build the entire app (obviously the libraries it uses are a lot more code).
Here is some sample code which shows how simple it is to send an SMTP message via Indy:
var
LMessage: TIdMessage;
LAddress: TIdEmailAddressItem;
begin
// send
LMessage := TIdMessage.Create(nil);
try
LAddress := LMessage.Recipients.Add;
//LAddress.Name := '';
LAddress.Address := SendToEdit.Text;
//LMessage.BccList.Add.Address := '';
//LMessage.From.Name := '';
LMessage.From.Address := SendFromEdit.Text;
LMessage.Body.Text := SendMemo.Lines.Text;
LMessage.Subject := SendSubjectEdit.Text;
IdSMTP1.Host := SettingsFDMemTable.FieldByName('SmtpHost').AsString;
IdSMTP1.Port := SettingsFDMemTable.FieldByName('SmtpPort').AsInteger;
IdSMTP1.Username := SettingsFDMemTable.FieldByName('SmtpUser').AsString;
IdSMTP1.Password := SettingsFDMemTable.FieldByName('SmtpPass').AsString;
case SmtpSSLCB.ItemIndex of
-1,0: IdSMTP1.UseTLS := utNoTLSSupport;
1: IdSMTP1.UseTLS := utUseExplicitTLS;
2: IdSMTP1.UseTLS := utUseImplicitTLS;
3: IdSMTP1.UseTLS := utUseRequireTLS;
end;
IdSMTP1.Connect;
try
IdSMTP1.Send(LMessage);
finally
IdSMTP1.Disconnect
end;
finally
LMessage.Free
end;
