Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Programmieren allgemein (https://www.delphipraxis.net/40-programmieren-allgemein/)
-   -   Delphi Outlook.Application Inspectors iterieren C# -> Delphi (https://www.delphipraxis.net/194798-outlook-application-inspectors-iterieren-c-delphi.html)

Towmuz 8. Jan 2018 08:43

Outlook.Application Inspectors iterieren C# -> Delphi
 
Moin,

könnt mich mal jemand in die richtige Richtung treten? Ich versuche durch die geöffneten Mails von Outlook iterieren
und bei einer bestimmten Mail einen Anhang hinzuzufügen.

In C# kriege ich das wie folgt zum Laufen:
Code:
using O = Microsoft.Office.Interop.Outlook;

O.Application app = new O.Application();
O.MailItem mail = null;

for (int i = 0; i < app.Inspectors.Count; i++)
{
   if (app.Inspectors[i + 1].Caption.Contains("Bestellung "))
   {
       mail = app.Inspectors[i + 1].CurrentItem;
       Console.WriteLine(mail.Subject);
   }
}

if (mail != null)
{
   mail.Attachments.Add(outFile);
}
Analog dazu in Delphi dachte ich mir dann folgendes:

Delphi-Quellcode:
var
  Inspector,
  Outlook,
  Mail: Variant;

  Outlook := GetActiveOleObject('Outlook.Application');
  for i := 0 to Outlook.Inspectors.Count - 1 do
  begin
    Inspector := Outlook.Inspectors[i + 1]; // Error: Unzulässige Parameteranzahl
    if Inspector.Caption.Contains('Bestellung') then
    begin
      mail := Outlook.Inspectors[i + 1].CurrentItem;
    end;
  end;

  mail.Attachments.Add(Anhang);
Nuja ich schätze mal, irgendwas fehlt, damit Delphi erkennt was Outlook.Inspectors für ein CollectionObject ist um es auch abfragen zu können.
Aus dem MSDN Artikel werde ich aber nicht sonderlich schlau.

mensch72 8. Jan 2018 08:53

AW: Outlook.Application Inspectors iterieren C# -> Delphi
 
https://msdn.microsoft.com/de-de/vba...method-outlook

Inspector := Outlook.Inspectors.Item(i + 1); // anstatt Inspector := Outlook.Inspectors[i + 1]

Towmuz 8. Jan 2018 09:00

AW: Outlook.Application Inspectors iterieren C# -> Delphi
 
Woah danke für die schnelle Antwort, funktioniert :-D

Da hab ich wohl immer an der falschen Stelle gesucht.


Alle Zeitangaben in WEZ +1. Es ist jetzt 13:29 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