Search results for 'SMTP Component'. 1 post(s) found.
- 2009/07/07 How to send email by TIdSMTP VCL ?
TIdSMTP Component is very useful VCL in Delphi 2009. Here's the simple example to Send email.
uses IdSMTP, IdMessage;;
procedure KMAIL( sTo, title, body:string);
var
IdMsg : TIdMessage;
begin
IdMsg := TIdMessage.Create(nil);
try
with TIdSMTP.Create(nil) do
try
UserName := SMTPFrm.m_username.Text;
Password := SMTPFrm.m_password.Text;
Host := SMTPFrm.m_host.Text;
IdMsg.Body.Add(body);
IdMsg.Recipients.emailAddresses := sTo;
IdMsg.Subject := title;
IdMsg.From.Address := SMTPFRm.m_email.Text;
IdMsg.From.Name := SMTPFRm.m_realname.Text;
Connect;
Send(IdMsg);
Disconnect;
finally
Free;
end;
finally
IdMsg.free;
end;
end;
procedure TMainFrm.Button1Click(Sender: TObject);
begin
KMAIL( 'foo@foo.com', 'Test mail from kurapa', 'Man, this is test mail from kurapa!!');
end;
procedure KMAIL( sTo, title, body:string);
var
IdMsg : TIdMessage;
begin
IdMsg := TIdMessage.Create(nil);
try
with TIdSMTP.Create(nil) do
try
UserName := SMTPFrm.m_username.Text;
Password := SMTPFrm.m_password.Text;
Host := SMTPFrm.m_host.Text;
IdMsg.Body.Add(body);
IdMsg.Recipients.emailAddresses := sTo;
IdMsg.Subject := title;
IdMsg.From.Address := SMTPFRm.m_email.Text;
IdMsg.From.Name := SMTPFRm.m_realname.Text;
Connect;
Send(IdMsg);
Disconnect;
finally
Free;
end;
finally
IdMsg.free;
end;
end;
procedure TMainFrm.Button1Click(Sender: TObject);
begin
KMAIL( 'foo@foo.com', 'Test mail from kurapa', 'Man, this is test mail from kurapa!!');
end;
As you can see above, you need Host, User ID, Password for sending email. In addition, you can define SMTP port as well.
Another posts included in "Delphi"
| Base64 Encoding/Decoding function for Delphi (0) | 2009/07/16 |
| How to encode subject content when sending mail with TIdMessage ? (0) | 2009/07/16 |
| How to send text/html based email in UTF-8 with TIdSMTP, TIdMessage VCL (0) | 2009/07/20 |
| How to return exit code such as exit() function in C/C++ ? (0) | 2009/07/02 |
| How to get parameter string ? (0) | 2009/06/30 |
| Save TBitmap image to Jpeg format image in Delphi (0) | 2009/06/26 |
| How to get screen resolution in case of using multiple monitors ? (0) | 2008/12/16 |
| How to turn off monitor ? (0) | 2008/12/10 |

Prev

Rss Feed