Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Netzwerke (https://www.delphipraxis.net/14-netzwerke/)
-   -   Delphi Thunderbird (https://www.delphipraxis.net/166722-thunderbird.html)

danten 27. Feb 2012 09:52

Thunderbird
 
Hello friends,
You can tell me how Exporting email addresses from Thunderbird.

I need to format "username" and "email0" "email1" .....

thank you

Nersgatt 27. Feb 2012 09:54

AW: Thunderbird
 
As far as i remember, Thunderbird uses the mbox-format: http://en.wikipedia.org/wiki/Mbox
I should read more carefully - sorry.

danten 27. Feb 2012 10:02

AW: Thunderbird
 
My point is, decrypt the file:
C:\Users\<user_name>\AppData\Roaming\Thunderbird\P rofiles\<profile_name>\abook.mab

Nersgatt 27. Feb 2012 10:39

AW: Thunderbird
 
Take a look at this wiki-article: http://en.wikipedia.org/wiki/Mork_%28file_format%29
There are also links to the description of the format.

exilant 27. Feb 2012 10:40

AW: Thunderbird
 
Zitat:

Zitat von danten (Beitrag 1153069)
My point is, decrypt the file:
C:\Users\<user_name>\AppData\Roaming\Thunderbird\P rofiles\<profile_name>\abook.mab

The Thunderbird address book is stored in a format called "Mork". It's a very sick fileformat. Don't waste your time trying to write MORK File I/O routines. Use the Thunderbird import/export functions.

Also read on wikipedia:

"...the single most braindamaged file format that I have ever seen in my nineteen year career"

danten 27. Feb 2012 10:44

AW: Thunderbird
 
oops,
and is there any possibility to programmatically export the contacts?

Now I thought that the file can be found in the @ sign and read from the recording marks to marks =)
Somehow use the Pos () and Find

Iwo Asnet 27. Feb 2012 12:20

AW: Thunderbird
 
There is a plugin available for Thunderbird which adds export/import functionality to the context menu. There is a chance that you will also get the source code.

hans ditter 27. Feb 2012 13:41

AW: Thunderbird
 
Don't know if I got you right, but in Thunderbird 10.0.2 it's possible to directly export a contact commy seperated, tabulator seperated or in LDIF format. Just open the address book, click "extras" and then export.

Hope that helps! ;)

danten 27. Feb 2012 13:58

AW: Thunderbird
 
I have it almost done.
I need only add a piece of code.
Something like:
Delphi-Quellcode:
  for i := 0 to Memo1.Lines.Count - 1 do
  begin
   if Memo1.Lines.Text <> '@' then
   begin
   ????????? Memo1.Lines[i] =>> Copy Memo2.Lines ????????????
If you can find on line and found the @ character to copy the line Memo2

Once that is functional, I put all the code here. :lol:

danten 27. Feb 2012 14:53

AW: Thunderbird
 
OK friends, here's my code that works. :thumb:

The file is loaded Memo1 abook.mab
Memo2 The resulting list is then e-mail addresses


Delphi-Quellcode:
procedure TForm1.ExtractAdress;
var
  pth,s1,s2:string;
  c1,c2,c3:integer;
  c,x,y:integer;
begin
  pth := 'C:\Users\<username>\AppData\Roaming\Thunderbird\Profiles\<profile_name>\abook.mab';
  s1 := '@';
  s2:= '<';
  memo1.Lines.LoadFromFile(pth);

  for y := 23 downto 0 do
    begin
      memo1.Lines.Delete(0);
    end;

  for c1 := 0 to Memo1.Lines.Count - 1 do
  begin
    memo1.lines[c1]:= (StringReplace(memo1.lines[c1],'=','='+#13#10,[rfReplaceAll]));
  end;

  for c2 := 0 to Memo1.Lines.Count - 1 do
  begin
    memo1.lines[c2]:= (StringReplace(memo1.lines[c2],')',''#13#10+'',[rfReplaceAll]));
  end;

  for c3 := 0 to Memo1.Lines.Count - 1 do
  begin
    memo1.lines[c3]:= (StringReplace(memo1.lines[c3],'@$${1{@','',[rfReplaceAll]));
    memo1.lines[c3]:= (StringReplace(memo1.lines[c3],'@$$}1}@','',[rfReplaceAll]));
    memo1.lines[c3]:= (StringReplace(memo1.lines[c3],'@$${3{@','',[rfReplaceAll]));
    memo1.lines[c3]:= (StringReplace(memo1.lines[c3],'@$$}3}@','',[rfReplaceAll]));
    memo1.lines[c3]:= (StringReplace(memo1.lines[c3],'@$${4{@','',[rfReplaceAll]));
    memo1.lines[c3]:= (StringReplace(memo1.lines[c3],'@$$}4}@','',[rfReplaceAll]));
    memo1.lines[c3]:= (StringReplace(memo1.lines[c3],'@$${5{@','',[rfReplaceAll]));
    memo1.lines[c3]:= (StringReplace(memo1.lines[c3],'@$$}5}@','',[rfReplaceAll]));
  end;

  for c := Memo1.Lines.Count - 1 downto 0 do
  begin
  if AnsiPos(s1, Memo1.Lines[c]) <> 0 then
    Memo2.Lines.Add(Memo1.Lines[c]);
  end;

  for x := Memo2.Lines.Count - 1 downto 0 do
  begin
  if AnsiPos(s2, Memo2.Lines[x]) <> 0 then
    Memo2.Lines.Delete(x);
  end;
end;

Nersgatt 28. Feb 2012 07:13

AW: Thunderbird
 
You should not (miss-) use a visual component for data manipulation. Instead of memo1.lines you could use a TStringList wich is acually very similar, since TMemo.Lines is a class of the type "TStrings" and a TStringList is inherited from TStrings.

himitsu 28. Feb 2012 09:15

AW: Thunderbird
 
Zitat:

Delphi-Quellcode:
  for c1 := 0 to Memo1.Lines.Count - 1 do
  begin
    memo1.lines[c1]:= (StringReplace(memo1.lines[c1],'=','='+#13#10,[rfReplaceAll]));
  end;

  for c2 := 0 to Memo1.Lines.Count - 1 do
  begin
    memo1.lines[c2]:= (StringReplace(memo1.lines[c2],')',''#13#10+'',[rfReplaceAll]));
  end;

  for c3 := 0 to Memo1.Lines.Count - 1 do
  begin
    memo1.lines[c3]:= (StringReplace(memo1.lines[c3],'@$${1{@','',[rfReplaceAll]));
    memo1.lines[c3]:= (StringReplace(memo1.lines[c3],'@$$}1}@','',[rfReplaceAll]));
    memo1.lines[c3]:= (StringReplace(memo1.lines[c3],'@$${3{@','',[rfReplaceAll]));
    memo1.lines[c3]:= (StringReplace(memo1.lines[c3],'@$$}3}@','',[rfReplaceAll]));
    memo1.lines[c3]:= (StringReplace(memo1.lines[c3],'@$${4{@','',[rfReplaceAll]));
    memo1.lines[c3]:= (StringReplace(memo1.lines[c3],'@$$}4}@','',[rfReplaceAll]));
    memo1.lines[c3]:= (StringReplace(memo1.lines[c3],'@$${5{@','',[rfReplaceAll]));
    memo1.lines[c3]:= (StringReplace(memo1.lines[c3],'@$$}5}@','',[rfReplaceAll]));
  end;

Warum jede Zeile einzeln, wo einmal über Alles auch ausgereicht hätte?
Warum s1 und s2 nichtssagende Variablen, anstatt direkte Konstanten sind, hab ich auch nicht ganz verstanden. (wenn ich ganz unten s1 lese, dann kommt mir kein @ in den Sinn, welches tausende Zeilen davor mal dort reingemacht wurde)

danten 28. Feb 2012 13:26

AW: Thunderbird
 
Zitat:

Zitat von himitsu (Beitrag 1153315)
Warum jede Zeile einzeln, wo einmal über Alles auch ausgereicht hätte?
Warum s1 und s2 nichtssagende Variablen, anstatt direkte Konstanten sind, hab ich auch nicht ganz verstanden. (wenn ich ganz unten s1 lese, dann kommt mir kein @ in den Sinn, welches tausende Zeilen davor mal dort reingemacht wurde)

I do not understand your question.
It does not work for you?

haentschman 28. Feb 2012 14:17

AW: Thunderbird
 
Hi...

he mean: Why do you use a Loop over the lines ? You ca also use the Property Text without a Loop :zwinker:
Example:
Delphi-Quellcode:
memo1.Text:= (StringReplace(memo1.Text,'@$${1{@','',[rfReplaceAll]))
.

PS: he is reading english, thinking german, writing german :lol:
PS2:
Once more...
Zitat:

You should not (miss-) use a visual component for data manipulation.
...the best Info you ever get 8-)

danten 28. Feb 2012 16:56

AW: Thunderbird
 
Oh yes.
I used the memo in the example just to see what it does, of course I have already used TStringList which is about 99% faster.

Thanks

danten 29. Feb 2012 07:09

AW: Thunderbird
 
It is this right?
Load approx. 15 addresses takes 10 seconds.

Thunderbird personal contacts:

Delphi-Quellcode:
type
  TForm1 = class(TForm)
    Button1: TButton;
    Memo2: TMemo;
    pb: TProgressBar;
    procedure Button1Click(Sender: TObject);
  private
    procedure ExtractAdress;
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1 : TForm1;
  pth : string;
  c,c1,x,y,i : integer;
  SL:TStringList;


implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
  memo2.Clear;
  ExtractAdress;
end;

procedure TForm1.ExtractAdress;
begin
  try
  pth := 'C:\Users\<user_name>\AppData\Roaming\Thunderbird\Profiles\<profile_name>\abook.mab';
  SL := TStringList.Create;

  try
    SL.LoadFromFile(pth);
   for y := 23 downto 0 do
    begin
      SL.Delete(0);
    end;

  pb.Max := SL.Count -1;
  i := SL.Count;

  for c1 := 0 to SL.Count - 1 do
  begin
    Application.ProcessMessages;
    pb.Position := c1;
    SL.text:= (StringReplace(SL.text,'=','='+#13#10,[rfReplaceAll]));
    SL.text:= (StringReplace(SL.text,')',''#13#10+'',[rfReplaceAll]));
    SL.text := (StringReplace(SL.text,'@$${1{@','',[rfReplaceAll]));
    SL.Text := (StringReplace(SL.text,'@$$}1}@','',[rfReplaceAll]));
    SL.text := (StringReplace(SL.Text,'@$${2{@','',[rfReplaceAll]));
    SL.Text := (StringReplace(SL.text,'@$$}2}@','',[rfReplaceAll]));
    SL.text := (StringReplace(SL.Text,'@$${3{@','',[rfReplaceAll]));
    SL.Text := (StringReplace(SL.text,'@$$}3}@','',[rfReplaceAll]));
    SL.text := (StringReplace(SL.text,'@$${4{@','',[rfReplaceAll]));
    SL.Text := (StringReplace(SL.text,'@$$}4}@','',[rfReplaceAll]));
    SL.text := (StringReplace(SL.Text,'@$${5{@','',[rfReplaceAll]));
    SL.Text := (StringReplace(SL.text,'@$$}5}@','',[rfReplaceAll]));
    SL.text := (StringReplace(SL.Text,'@$${6{@','',[rfReplaceAll]));
    SL.Text := (StringReplace(SL.text,'@$$}6}@','',[rfReplaceAll]));
    SL.text := (StringReplace(SL.text,'@$${7{@','',[rfReplaceAll]));
    SL.Text := (StringReplace(SL.text,'@$$}7}@','',[rfReplaceAll]));
    SL.text := (StringReplace(SL.Text,'@$${8{@','',[rfReplaceAll]));
    SL.Text := (StringReplace(SL.text,'@$$}8}@','',[rfReplaceAll]));
    SL.text := (StringReplace(SL.Text,'@$${9{@','',[rfReplaceAll]));
    SL.Text := (StringReplace(SL.text,'@$$}9}@','',[rfReplaceAll]));
  end;

  for c := SL.Count - 1 downto 0 do
  begin
  if AnsiPos('@', SL[c]) <> 0 then
    Memo2.Lines.Add(SL[c]);
  end;

  for x := Memo2.Lines.Count - 1 downto 0 do
  begin
  if AnsiPos('<', Memo2.Lines[x]) <> 0 then
    Memo2.Lines.Delete(x);
  end;
  finally
    SL.Free;
    pb.Position := 0;
    if memo2.Text <> '' then
      ShowMessage('Email addresses successfully completed')
    else
      ShowMessage('There are no email addresses');
  end;
  except
    ShowMessage('Could not load file abook.mab');
  end;
end;


Alle Zeitangaben in WEZ +1. Es ist jetzt 02:27 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz