procedure TFEMailEdit.btSendClick(Sender: TObject);
var
i : integer;
function GetRichEditText(
const Edit:TRxRichEdit) :
string;
var
stream : TMemoryStream;
pData : PChar;
begin
Result := '
';
stream := TMemoryStream.Create;
try
edit.Lines.SaveToStream(stream);
pData := stream.Memory;
Result := pData;
IdMsgSend.Body.SetText(pData);
except
end;
stream.Free;
end;
begin
SMTP.AuthenticationType := atNone;
if SMTP.Connected
then
begin
IdMsgSend.ContentType := '
application/rtf';
case rgEncoding.ItemIndex
of
0: IdMsgSend.Encoding := meMime;
1: IdMsgSend.Encoding := meUU;
end;
IdMsgSend.From.Text := Trim(edUserId.Text)+'
'+Trim(edFromAdress.Text);
IdMsgSend.ReplyTo.EMailAddresses := Trim(edFromAdress.Text);
IdMsgSend.Recipients.EMailAddresses := CharRem(#10+#13,meToAddress.lines.Text);
IdMsgSend.CCList.EMailAddresses := edToCarbonCopy.lines.Text;
IdMsgSend.BccList.EMailAddresses := meToBlindCarbonCopy.lines.Text;
GetRichEditText(edText);
//IdMsgSend.Body.SetText(edText.Lines.GetText); //.Assign(edText.Lines);
IdMsgSend.MessageParts.Clear;
for i := 0
to lbAttachment.Items.Count-1
do
begin
TIdAttachment.Create(IdMsgSend.MessageParts, lbAttachment.items.Text);
end;
IdMsgSend.Subject := edSubject.Text;
IdMsgSend.ReplyTo.EMailAddresses := edFromAdress.Text;
try
SMTP.Send(IdMsgSend);
//SMTP.ClearParameters;
SMTP.DisConnect;
Connect;
if lDelAttachAfterSuccess
then
begin
for i := 0
to lbAttachment.Items.Count-1
do
begin
if not FErase(lbAttachment.Items[i])
then
FMain.WriteMailProt(coLogError, [edSubject.Text, '
Attachment: '+lbAttachment.Items[i]+'
konnte nicht gelöscht werden.', '
btSendClick', cPubLoginName]);
end;
end;
except
on e:
Exception do
begin
if not lAutoMail
then ShowMessage('
Ein Fehler ist aufgetreten.'+#13+e.
Message);
lbStatus.items.add( '
Sendefehler ... Adresse richtig ?');
lbStatus.ItemIndex := lbStatus.Items.Count-1;
FMain.WriteMailProt(coLogError, [edSubject.Text, lbStatus.Items[lbStatus.Items.Count-1], '
btSendClick', cPubLoginName]);
end;
end;
end;
end;