Discuss this help topic in SecureBlackbox Forum
SMTP: Send the message
Use different variants of Send() method to send an email. The simplest way to create and send an e-mail message is to create an instance of TElSimpleMIMEMessage and send it:
C#:
TElSimpleMIMEMessage msg = new TElSimpleMIMEMessage();
msg.From = "me@company.com";
msg.To_.Add("boss@company.com");
msg.Subject = "Test message";
msg.BodyPlain.Text = "Just a test message";
smtp.Send(msg);
Delphi:
var msg : TElSimpleMIMEMessage;
...
Msg := TElSimpleMIMEMessage.Create();
Msg.From := 'me@company.com';
Msg.To_.Add('boss@company.com');
Msg.Subject := 'Test message';
msg.BodyPlain.Text := 'Just a test message';
smtp.Send(msg);
Also it is possible to send a message from files or streams.
Usually, messages are sent in text mode line-by-line. Lines in SMTP protocol are limited in length by 1000 bytes for new servers; old servers can limit lines at 79 bytes. For large messages, this could result in very slow sending speed. But if the server supports the binary chunking mode (see ExtensionBinarySupported and ExtensionChunkingSupported properties), it is possible to send messages in chunks. To allow this, set AllowBinary property to 'true' and BinaryChunkSize property to the necessary chunk size in bytes. Use of the binary mode can speed-up message sending process.
Examples:
C#:
if (smtp.ExtensionBinarySupported)
{
// enable to send messages in binary mode
smtp.AllowBinaryMode = true;
// send messages by 100KB chunks
smtp.BinaryChunkSize = 102400;
}
smtp.Send(msg);
Delphi:
if smtp.ExtensionBinarySupported then
begin
// enable to send messages in binary mode
smtp.AllowBinaryMode := true;
// send messages by 100KB chunks
smtp.BinaryChunkSize := 102400;
end;
smtp.Send(msg);