I've not found any documentation about TScMailMessage, so I ask here.
Sending Messages over 73 Charakters causes line breaks at positions I don't want.
Reason is the Quoted-printable-Encoding.
My code is
Code: Select all
procedure TBafWebModule.EmailSend;
var
LMess: TScMailMessage;
LAttach: TScAttachment;
i, LCount: integer;
begin
if not FMailClient.Active then
FMailClient.Connect;
if FMailClient.Authenticate then begin
LMess := TScMailMessage.Create;
try
LMess.Encoding := meMIME;
LMess.From.AsString := FindParamStringReplaced('from', '');
LMess.ReplyTo.AsString := FindParamStringReplaced('reply', '');
LMess.ToAddress.AsString := FindParamStringReplaced('to', '');
LMess.CC.AsString := FindParamStringReplaced('cc', '');
LMess.BCC.AsString := FindParamStringReplaced('bcc', '');
LMess.Subject := FindParamStringReplaced('subject', '');
LMess.Body.Text := FindParamStringReplaced('text', '');
LMess.BodyEncoding := 'multipart';
LCount := FindParamIntegerReplaced('cnt', 0);
for i := 1 to LCount do begin
LAttach := TScAttachment.Create(LMess.Attachments,
FindParamStringReplaced('fn' + IntToStr(i), ''));
end;
FMailClient.Send(LMess);
finally
LMess.Free;
end;
end
else
FInter.DoLog('E', '#email_send, authenification failed');
end;
A workaround is to remove the last lines in TScCoderQuotedPrintable.InternalEncode. (I don't think, the problem is in this routine, but in using this encoding in this case. But it solves the problem in my project...)
Code: Select all
procedure TScCoderQuotedPrintable.InternalEncode(const Data: TBytes; Offset, Count: integer;
var OutBuf: TBytes; OutOffset: integer; out OutCount: integer);
var
EndPos, LineLen: integer;
i: integer;
begin
OutCount := Count * 3 + ((Count div 73) + 2) * 3;
if Length(OutBuf) < OutOffset + OutCount then
SetLength(OutBuf, OutOffset + OutCount);
OutCount := 0;
LineLen := 0;
EndPos := Offset + Count - 1;
for i := Offset to EndPos do begin
if (Data[i] >= 33) and (Data[i] <= 126) and (Data[i] <> 61{=}) then begin
OutBuf[OutOffset] := Data[i];
Inc(OutOffset);
Inc(OutCount);
Inc(LineLen);
end
else
if ((Data[i] = 9) or (Data[i] = 32)) and (i < EndPos) then begin
OutBuf[OutOffset] := Data[i];
Inc(OutOffset);
Inc(OutCount);
Inc(LineLen);
end
else begin
OutBuf[OutOffset] := 61{=};
OutBuf[OutOffset + 1] := Ord(TwoHexUpperLookup[Data[i]][1]);
OutBuf[OutOffset + 2] := Ord(TwoHexUpperLookup[Data[i]][2]);
Inc(OutOffset, 3);
Inc(OutCount, 3);
Inc(LineLen, 3);
end;
// if (LineLen >= 73) and (i < EndPos) then begin
// OutBuf[OutOffset] := 61{=};
// OutBuf[OutOffset + 1] := 13;
// OutBuf[OutOffset + 2] := 10;
// Inc(OutOffset, 3);
// Inc(OutCount, 3);
// LineLen := 0;
// end;
end;
end;
Documentation would be nice...