Hi,
You might want to try reading some of the source files; they're provided (at
least with my copy of Delphi). BrowseSymbol can often get you there.
atLogin and atNone are symbolic constants, and have to be one value or the
other. Choose according to whether or not your server requires
authentication (mine all do). If you specify atLogin, then you need the
UserName and PassWord fields (specify the appropriate string constants for
your account on your server).
Message
From: "Alan Colburn" <aicolburn (AT) hotmail (DOT) com>
To: "Borland's Delphi Discussion List" <delphi (AT) elists (DOT) org>
Sent: Friday, November 04, 2005 12:43 PM
Subject: Re: Want to access default mail client
Hi Ranier --
Thanks for your post here. As it turns out, I'm now just starting to try
coding a simple eMail sender, so your post is perfect for me.
Can you help a little with one of the lines of code:
SMTP.AuthenticationType := atLogin;
My knowledge about SMTP is a little skimpy'll look around and learn
some more, as I understand it, some servers will need authentication
and some won't. Can you tell me a little more about how that part of the
process works? How would you write the code in a way that would work
universally? In addition, I'm a little uncertain about the atLogin
variable. Is this something you declared? Is it placeholder text, like
'Email password'?
Thanks! -- Al C.
Message
From: "Rainer von Saleski" <rainer (AT) vonsaleski (DOT) com>
To: "Borland's Delphi Discussion List" <delphi (AT) elists (DOT) org>
Sent: Tuesday, November 01, 2005 1:09 PM
Subject: Re: Want to access default mail client
>
>
>There is a very nice Email-sender built into Delphi 7 (it may also be
>available in earlier versions) as part of Indy.
>>
>You can find a write-up (with some omissions) at
>
>>
>Here is my wrapper for creating and sending Emails. Just call the
>procedures in the order they appear here (as often as necessary). Be
>sure
>to change the text strings in EmailInit to reflect your own email
>account.
>>
>Rainer
>>
>>
>[Begin Code]
>>
>unit EmailUnit;
>>
>interface
>>
>uses
>inifiles, Windows, Messages, SysUtils, Variants, Classes, Graphics,
>Controls, Forms,
>Dialogs, IdComponent, IdTCPConnection, IdTCPClient, IdMessageClient,
>IdSMTP, ComCtrls, StdCtrls, Buttons, ExtCtrls,
>IdBaseComponent, IdMessage, IdEmailAddress;
>>
>type
>TEmail = class (TForm)
>MailMessage: TIdMessage;
>SMTP: TIdSMTP;
>end;
>>
>var
>Email: TEmail;
>procedure EmailInit (FromName, FromAddr, Subject: string; Body:
>TStrings);
>procedure EmailTo (ToName, ToAddr: string); {May be called more than
>once}
>procedure EmailAttach (FileName: string); {May be called more than
>once}
>procedure EmailSend;
>>
>implementation
>>
>{$R *.dfm}
>>
>procedure EmailInit (FromName, FromAddr, Subject: string; Body:
>TStrings);
>begin with Email do begin
>>
>// SMTP Host
>SMTP.Host :='Email SMTP Server';
>SMTP.Port := 25;
>>
>// User Name and Password
>SMTP.AuthenticationType := atLogin; // or atNone if your host doesn't
>casre who you are
>SMTP.Username := 'Email User Name';
>SMTP.Password := 'Email Password';
>>
>// Message Parts
>MailMessage.Clear;
>MailMessage.From.Name := FromName;
>MailMessage.From.Address := FromAddr;
>MailMessage.Recipients.Clear;
>MailMessage.Subject := Subject;
>MailMessage.Body.Text := Body.Text;
>end end;
>>
>procedure EmailTo (ToName, ToAddr: string);
>var
>EI: TIdEMailAddressItem;
>begin with Email do begin
>EI := MailMessage.Recipients.Add;
>EI.Name := ToName;
>EI.Address := ToAddr;
>end end;
>>
>procedure EmailAttach (FileName: string);
>begin with Email do begin
>if FileExists(FileName)
>then TIdAttachment.Create(MailMessage.MessageParts, FileName)
>else ShowMessage (format ('Attachment "%s" not found', [FileName]));
>end end;
>>
>procedure EmailSend;
>begin with Email do begin
>try
>try
>SMTP.Connect(1000);
>SMTP.Send(MailMessage);
>except on E:Exception do
>ShowMessage ('Email Error: ' + E.Message);
>end;
>finally
>if SMTP.Connected then SMTP.Disconnect;
>end;
>end end;
>>
>end.
>>
>[End of Code]
>>
>
>Delphi mailing list -Delphi (AT) elists (DOT) org
>
>>
>
Delphi mailing list -Delphi (AT) elists (DOT) org