RE: TZF - Email from Delphi App
Brian <[email protected]> Fri, 19 Mar 2004 15:48:39 +1100
| Newsgroups | gmane.comp.lang.delphi.topaz |
|---|---|
| Message-ID | <[email protected]> |
Using MAPI is OK if you have MAPI based email client software installed and
it is correctly configured on the computer.
However, this suffers in that the message appears to come from the
configured local user - which may NOT be what you want AND this arrangement
can be a real problem if you need to send messages from a 'service' on a
server or, more importantly, from several servers/services which form a
common system
I always use the INDY IdSMTP component as I can always "reach" an SMTP
server - these days "every" real mail system has an SMTP interface
(Aside : an SMTP server comes as part of the MS IIS installation on servers)
I have never had to resort to using more than the IdSMTP.QuickSend method
(However, I only use email messaging for 'quick' info - ie "application
received", "item overdue", etc and include a URL link to the relevant
document/information in the body of the message)
As you have full control over the "sender address entry" you can tailor the
message to indicate that it came from a different "engine"
ie. I have a multi-service server, with clients connecting to different
"services", messages sent from the various parts of the system appear to the
clients as coming from "WebMaster" or the "Data Manager" or the "System
Administrator" as required/appropriate even though differing message types
may have come from a single service - a little difficult to do if using
MAPI.
Notes:
You need to can specify either IP or DNS_Name for the SMTP_ServerAddress
The body text string can be assigned from a TStringList, etc - could be
quite large (I do not know the limits here - you would need to refer to the
INDY doco)
Some (many?) SMTP servers have SPAM filters - you will need to comply with
the rules for the one you will be accessing else your messages will get
'bounced/dropped'
For multiple addresses, easiest to use a loop to send to each address
If you need more than the simple "QuickSend" (ie. attachments) you can use
the full power of the component
----------------------------------------------------------
Very minimal app
Eg.
Start a new app,
Drop a button & an IdSMTP component on the form
Set the Button's OnClick method
Clicking the button sends the message
----------------------------------------------------------
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, IdBaseComponent, IdComponent, IdTCPConnection,
IdTCPClient, IdMessageClient, IdSMTP;
type
TForm1 = class(TForm)
IdSMTP1: TIdSMTP;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
IdSMTP1.QuickSend( SMTP_ServerAddress,
TheSubject,
Recipient,
FromEmailAddress,
BodyText );
end;
end.
--^----------------------------------------------------------------
This email was sent to: [email protected]
EASY UNSUBSCRIBE click here: http://topica.com/u/?clvXPN.a5kvff.Z2NsZHQt
Or send an email to: [email protected]
For Topica's complete suite of email marketing solutions visit:
http://www.topica.com/?p=TEXFOOTER
--^----------------------------------------------------------------