Delphi - HTML Formatted Mail - don't automatically download pictures
I wrote an email client and I am using profDHTMLEdit to display received, html formatted email message.
I want to have an option to prevent automatically downloading pictures, simmilar to the way outlook does it.
Thanks.
Thanks, this looks like a good start. I will give it a try today.
I'm just thinking how to implement displaying a substitute 'frame' that is placed where the picture was and finally how to do the 'Download Pictures'. (like in outlook)
For the latter I think a re-reading of the message from the server.
graga
ThievingSix
Well, you could just save the original html and if they want the pictures you just replace the edited version with the original. One less GET to the server. You could just remove the picture completely. Or you can substitute your own picture there.
graga
ASKER
Hi,
I think I've got it.
I parse for '<imv ' and in the first ' src=' I insert some code. like [BlockedImageLink].
The displayed html preserves the location and size of the images, but does not display anything
To revert, I remove the inserted code from html.
I'm using madshi string libraries in the code.
I will give you points for pointing me in the right direction.
so here it is:
function BlockImageLinks(Source: string): string;
var ImgPos, SrcPos: Integer;
FromPos, ToPos: Integer;
c: char;
begin
Result := '';
FromPos := 1;
ToPos := Length(Source);
// process all occurences of '<img ' substring
ImgPos := PosStr('<img ', LowerCase(Source), FromPos, Length(Source));
while ImgPos > 0 do begin
// find ' src=' substring following the '<img ' substring
SrcPos := PosStr(' src=', LowerCase(Source), ImgPos+1, Length(Source));
if SrcPos > 0 then begin
Result := Result + Copy(Source, FromPos, (SrcPos + 6) - FromPos) + '[BlockedImageLink]';
FromPos := SrcPos + 6;
while FromPos < Length(Source) do begin
// search for the closing '>'
c := Source[FromPos];
Result := Result + c;
inc(FromPos);
if c = '>' then
Break;
end;
end
else begin
// something is wrong with html code, return the original html
Result := Source;
Exit;
end;
I'm just thinking how to implement displaying a substitute 'frame' that is placed where the picture was and finally how to do the 'Download Pictures'. (like in outlook)
For the latter I think a re-reading of the message from the server.
graga