Einzelnen Beitrag anzeigen

Benutzerbild von erich.wanker
erich.wanker

Registriert seit: 31. Jan 2008
Ort: im schönen Salzburger Land
454 Beiträge
 
Delphi XE4 Professional
 
#11

AW: Outlook: Mailadresse der aktuell fokusierten Mail

  Alt 12. Apr 2012, 17:50
Hab es jetzt geschafft ..

Vielen Dank an Alle!

Mit freundlichen Grüßen
Erich


Delphi-Quellcode:

procedure TForm1.SpeedButton2Click(Sender: TObject);
var
    i,j : Integer;
    NmSpace : OleVariant;
    Nachricht,MyReply : MailItem;
    ARecipient : Recipient;
    seMailAddress : String;
    MailRecipients, ReplyRecipients : Recipients;

Begin

OutlookApplication1.Connect;
NmSpace := OutlookApplication1.GetNamespace('MAPI');
NmSpace.Logon ('', '', False, False);


//ShowMessage('Anzahl markierte Mails: '+ inttostr(OutlookApplication1.ActiveExplorer().Selection.Count));

try
if OutlookApplication1.ActiveExplorer().Selection.Count > 0 then
begin
          Nachricht:= OutlookApplication1.ActiveExplorer.Selection.Item(1) as _MailItem;
          label1.Caption:=(
          'Sender : '+Nachricht.SenderName+#13+
          'Subjekt : '+Nachricht.Subject+#13+
          'Mailadresse : '+Nachricht.SenderName+#13+
          'Empfänger : '+Nachricht.To_);



    memo1.Lines.Clear;


    MyReply := Nachricht.Reply;
    MailRecipients := Nachricht.Recipients;
    ReplyRecipients := MyReply.Recipients;


    for j := 1 to MailRecipients.Count do
    Begin
    ARecipient := MailRecipients.Item(j);
    seMailAddress := ARecipient.Address;
    If Pos('@',seMailAddress) > 0 Then memo1.Lines.Append('* '+seMailAddress);
    End;


    for j := 1 to ReplyRecipients.Count do
    Begin
        ARecipient := ReplyRecipients.Item(1);
        seMailAddress := ARecipient.Address;
        If Pos('@',seMailAddress) > 0 Then
         begin
          memo1.Lines.Append('+ '+seMailAddress);
          label2.Caption:= seMailAddress;
         end;
    end;

end; // if OutlookApplication1.ActiveExplorer().Selection.Count > 0

except
Label2.Caption:='Fucking Fehler';
end;

end;// procedure

end.
Erich Wanker - for life:=1971 to lebensende do begin ..
O
/H\
/ \
  Mit Zitat antworten Zitat