Announcement

Collapse
No announcement yet.

Mit Delphi einen Termin in Outlook2000 eintragen?

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Mit Delphi einen Termin in Outlook2000 eintragen?

    Hallo Andreas,

    vor ca zwei Monaten hast Du mit ein Beispiel für den Termineintrag mit Delphi in Outlook gegeben. Bei Outlook97 klappte es. Nun haben wir auf Outlook 2000 umgestellt und schon ist das schöne arbeiten vorbei. Mit dem gelichen Code schlägt die Eintragung fehl. Weißt Du da schon was?

  • #2
    Hallo Markus,

    <p>hat es sich dabei um ein Beispiel für einen <em>Late bound-</em>Aufruf
    (via IDispatch) oder einen <em>Early bound</em>-Aufruf (über
    eines der Dual Interfaces von Outlook) gehandelt? An exakt
    welcher Stelle treten die Probleme mit <strong>Outlook 2000</strong>
    auf? Ist das Problem beseitigt, wenn im folgenden Listing der
    Wert &quot;<font color="#FF0000">Outlook.Application.8&quot; </font>durch<font
    color="#FF0000"> &quot;Outlook.Application.9&quot;</font> oder <font
    color="#FF0000">&quot;Outlook.Application&quot; </font>ersetzt
    wird?</p>

    <pre><strong>uses</strong> ComObj;

    <strong>const</strong>
    olFolderCalendar = 9;

    <strong>function</strong> E_AddCalendarItem(const pDate, pSubject,
    pLocation, pBody: PChar): Integer; <strong>stdcall</strong>;
    <strong>var</strong>
    aOutlook : Variant;
    aMAPI : Variant;
    aCalendar : Variant;
    sDate : String;
    sSubject : String;
    sLocation : String;
    sBody : String;
    <strong>begin</strong>
    Result := 0;
    <strong>try</strong>
    sDate := pDate;
    sSubject := pSubject;
    sLocation := pLocation;
    sBody := pBody;
    aOutlook := CreateOleObject('<font color="#FF0000">Outlook.Application.8</font>');
    <strong>try</strong>
    aMAPI := aOutlook.GetNameSpace('MAPI');
    aCalendar := aMAPI.GetDefaultFolder(olFolderCalendar).Items.Add ;
    aCalendar.Start := StrToDateTime(sDate);
    aCalendar.Subject := sSubject;
    aCalendar.Location := sLocation;
    aCalendar.Body := sBody;
    aCalendar.Save;
    Result := 1;
    <strong>finally</strong>
    aOutlook := Unassigned;
    <strong>end</strong>;
    <strong>except</strong>
    // Exceptions für <em>SQLWindows/32</em> abfangen !!!
    <strong>end</strong>;
    <strong>end</strong>;</pre>

    P.S. Die Funktion stammt aus einer Delphi-DLL, die COM-Funktionen für die Entwicklungsumgebungen nachrüstet, die mit COM auf Kriegsfuß stehen ;-)
    &#10

    Comment


    • #3
      Hallo Markus,

      ich habe das Ganze jetzt einmal mit Delphi 5 und Outlook 2000 ausprobiert: Das folgende <i>Early bound</i>-Beispiel aus meinem COM/DCOM-Buch legt auch für Outlook2000 einen neuen Kalendertermin an:

      <pre>procedure TFormMain.BitBtnCalendarClick(Sender: TObject);
      var
      aOutlook : _DApplication;
      aMAPI : NameSpace;
      aFolder : MAPIFolder;
      aCalendar : AppointmentItem;
      begin
      StatusBar1.SimpleText := 'Termin wird in Outlook eingetragen...';
      dwStart := GetTickCount;
      Screen.Cursor := crHourglass;
      aOutLook := CoApplication_.Create;
      try
      aMAPI := aOutlook.GetNameSpace('MAPI');
      aFolder := aMAPI.GetDefaultFolder(olFolderCalendar);
      aCalendar := aFolder.Items.Add(olAppointmentItem) as AppointmentItem;
      aCalendar.Start := EncodeTime(9, 0, 0, 0) + Int(DateTimePicker1.Date);
      aCalendar.Duration := 60;
      aCalendar.Subject := EditSubject.Text;
      aCalendar.ReminderMinutesBeforeStart := 30;
      aCalendar.ReminderPlaySound := True;
      aCalendar.ReminderSet := True;
      aCalendar.Location := EditLocation.Text;
      aCalendar.Body := MemoBody.Text;
      aCalendar.Save;
      finally
      aOutlook := nil;
      Screen.Cursor := crDefault;
      end;
      dwEnd := GetTickCount;
      StatusBar1.SimpleText := Format('Ausführungszeit: %d Windows-Ticks', [dwEnd - dwStart]);
      end;
      </pre>

      Die dazu eingebundene importierte Typbibliothek <b>Outlook_TLB.pas</b> stammt noch von Outlook 97

      Comment

      Working...
      X