OutlookEX UDF - Terminanfrage mit HTML-Body

  • Hallo,

    ich nutze das OutlookEx UDF zur Erstellung von Terminanfragen.

    Die Terminanfragen werden stets im Plaintext dargestellt. Gern hätte ich einen Bodytext in HTML. Aktuell wird der HTMLCode nicht als HTML interpretiert. Mit dem RTF Format besteht selbiges Problem.

    Zum Beispiel: In Word2010 erzeuge ich eine Vorlage, die dann mit "Speichern unter" in einem HMTL (gefiltert) Format gespeichert wird.

    Anschließend lese ich diese HTML Datei mit FileOpen ein und speichere den Quellcode in $bn_tf1.

    In der E-Mailerzeugung kann dieser HTMLCode direkt eingelesen werden und wird korrekt angezeigt im Outlook.

    Mein Ziel und Frage ist es, wie bekomme ich diesen HTMLCode in einen TaskItem / AppointmetItem?

    Ein Ausschnitt aus der OutlookEx Hilfe mit Anpassungen:

    [autoit]


    $oItem = _OL_ItemCreate($oOutlook, $olAppointmentItem, "*\Kalender", "", "Subject=TestEinladung", "Start=" & _NowCalc(), "End=" & _DateAdd("h", 1, _NowCalc()), "Location=Building A, Room 10", "RequiredAttendees=abc@xyz.de","Body="&$bn_tf1)

    [/autoit]

    Was ist falsch oder wie erreiche ich das Ziel?

    Danke und Gruß

    Einmal editiert, zuletzt von qwert23 (7. Dezember 2012 um 16:01)

  • Outlook unterstützt für Appointments nur RTF.
    Statt der Property "Body" setzt du einfach "RTFBody ".

  • Hallo Water,

    mit der Ergänzung "RTFBody" erscheint gar kein Text. Einzig mit der Anweisung "Body=".

    Ist dazu noch aus Deinem Verweis der "Inspector" zu setzen. Wie lautet dazu die Anweisung in Autoit?

    Ich habe die Kombination mit "BodyFormat=" ebenso erfolglos probiert.

    Ist das verständlich und kannst Du Dir das bitte nochmals ansehen?

    Danke und Gruß

  • Hab's selber noch nie gemacht.
    Mit dem Inspector rufst Du den Word Editor auf und gibst dann den Text über das Word Objektmodell ein.
    Beispiel hier.

  • Beispiel:

    [autoit]

    #AutoIt3Wrapper_AU3Check_Parameters= -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
    #AutoIt3Wrapper_AU3Check_Stop_OnWarning=Y
    #include <OutlookEX.au3>

    [/autoit][autoit][/autoit][autoit]

    ; *****************************************************************************
    ; Create test environment
    ; *****************************************************************************
    Global $oItem
    Global $oOutlook = _OL_Open()
    If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error creating a connection to Outlook. @error = " & @error & ", @extended = " & @extended)
    Global $Result = _OL_TestEnvironmentCreate($oOutlook)
    If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF - Manage Test Environment", "Error creating the test environment. @error = " & @error & ", @extended = " & @extended)

    [/autoit][autoit][/autoit][autoit]

    ; *****************************************************************************
    ; Example 1
    ; Create an appointment with subject, start- and enddate.
    ; Attendee is the current user
    ; *****************************************************************************
    Global Const $wdCollapseStart = 1 ; Collapse the range to the starting point
    $oItem = _OL_ItemCreate($oOutlook, $olAppointmentItem, "*\Outlook-UDF-Test\TargetFolder\Calendar", "", "Subject=TestSubject", "Start=" & _NowCalc(), "End=" & _DateAdd("h", 3, _NowCalc()), _
    "Location=Building A, Room 10", "RequiredAttendees=" & $oOutlook.GetNameSpace("MAPI" ).CurrentUser.Name)
    Global $oDoc = $oItem.GetInspector().WordEditor
    Global $oRange = $oDoc.Range
    $oRange.Collapse($wdCollapseStart)
    $oRange.InsertBefore("Inserted text at the start! ")
    $oItem.Display()
    _OL_Close($oOutlook)

    [/autoit]
  • Hallo Water,
    schon mal vielen Dank für Deine Unterstützung.
    In meiner Office2010 Umgebung erscheint kein Text im Body. Es erfolgen keine Fehlermeldungen.

    Siehst Du noch eine Chance für eine globale Lösung?

  • Du kannst Dir ja mal nach jedem Befehl beginnend mit Zeile "... $oItem.GetInspector().WordEditor" den Wert von @error ausgeben lassen.
    Alles 0?

  • Das habe ich nun jeweils mit dieser Anweisung getan:
    msgbox(0,"Errormeldung",@error)

    Global $oDoc = $oItem.GetInspector().WordEditor = 0
    Global $oRange = $oDoc.Range = 2
    $oRange.Collapse($wdCollapseStart) = 169
    $oRange.InsertBefore("Inserted text at the start! ") = 169
    $oItem.Display() = -2147352567

  • Ich bekomme immer 0 :wacko:
    Füge mal nach _OL_Open die Zeile

    [autoit]

    _OL_ErrorNotify(2)

    [/autoit]

    ein

  • Was mich wundert, ist der Returncode von

    [autoit]

    $oItem.Display() = -2147352567

    [/autoit]

    Bist Du sicher, dass das Appointment Objekt angelegt wurde?

  • Sehr, sehr seltsam. Kannst Du bitte zur Sicherheit das Skript posten mit dem Du diese Ergebnisse erzielst?

  • Hallo Water,

    es ist exakt Dein Script mit der Ergänzung zur Fehlerüberwachung _OL_ErrorNotify(2).

    [autoit]

    #AutoIt3Wrapper_AU3Check_Parameters= -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
    #AutoIt3Wrapper_AU3Check_Stop_OnWarning=Y
    #include <OutlookEX.au3>
    ; *****************************************************************************
    ; Create test environment
    ; *****************************************************************************
    Global $oItem
    Global $oOutlook = _OL_Open()
    _OL_ErrorNotify(2)
    If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error creating a connection to Outlook. @error = " & @error & ", @extended = " & @extended)
    Global $Result = _OL_TestEnvironmentCreate($oOutlook)
    If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF - Manage Test Environment", "Error creating the test environment. @error = " & @error & ", @extended = " & @extended)
    ; *****************************************************************************
    ; Example 1
    ; Create an appointment with subject, start- and enddate.
    ; Attendee is the current user
    ; *****************************************************************************
    Global Const $wdCollapseStart = 1 ; Collapse the range to the starting point
    $oItem = _OL_ItemCreate($oOutlook, $olAppointmentItem, "*\Outlook-UDF-Test\TargetFolder\Calendar", "", "Subject=TestSubject", "Start=" & _NowCalc(), "End=" & _DateAdd("h", 3, _NowCalc()), _
    "Location=Building A, Room 10", "RequiredAttendees=" & $oOutlook.GetNameSpace("MAPI" ).CurrentUser.Name)
    Global $oDoc = $oItem.GetInspector().WordEditor
    Global $oRange = $oDoc.Range
    $oRange.Collapse($wdCollapseStart)
    $oRange.InsertBefore("Inserted text at the start! ")
    $oItem.Display()
    _OL_Close($oOutlook)

    [/autoit]

    Falls es nun gar nicht funktionieren sollte, dann lebe ich auch mit dem Plaintext.

  • Der Gag ist ja: Bei mir funktioniert es!
    Windows 7 64 bit, Outlook und Word 2010 32 bit.
    Ich kann mir nur vorstellen, dass es von einer unterschiedlichen Konfiguration abhängt. Wie unterscheidet sich Dein Rechner?

  • Hallo Water,

    nun hast Du so viel Zeit und Arbeit investiert - Vielen vielen Dank dafür.
    Ich arbeite mit einem Dell XPS Ultrabook und ich wüßte nicht, was Auswirkungen haben könnte.

    Die erste Fehlermeldung verweist darauf, dass eine Deklaration (Not an Object Type) nicht korrekt ist, oder?
    Diese Meldung bezog sich auf diese Zeile:
    Global $oRange = $oDoc.Range
    Was könnte hierzu anders deklariert werden?

  • Die Meldung bezieht sich darauf, dass $oDoc kein Objekt ist.
    Ist auf Deinem Ultrabook Microsoft Word installiert?

  • Keine Idee warum das bei Dir nicht läuft:
    Hier nochmals eine Version mit etwas mehr Debugging code:

    [autoit]

    #AutoIt3Wrapper_AU3Check_Parameters= -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
    #AutoIt3Wrapper_AU3Check_Stop_OnWarning=Y
    #include <OutlookEX.au3>

    [/autoit][autoit][/autoit][autoit]

    ; *****************************************************************************
    ; Create test environment
    ; *****************************************************************************
    Global $oItem
    Global $oOutlook = _OL_Open()
    If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error creating a connection to Outlook. @error = " & @error & ", @extended = " & @extended)
    Global $Result = _OL_TestEnvironmentCreate($oOutlook)
    If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF - Manage Test Environment", "Error creating the test environment. @error = " & @error & ", @extended = " & @extended)

    [/autoit][autoit][/autoit][autoit]

    ; *****************************************************************************
    ; Example 1
    ; Create an appointment with subject, start- and enddate.
    ; Attendee is the current user
    ; *****************************************************************************
    _OL_ErrorNotify(2)
    Global Const $wdCollapseStart = 1 ; Collapse the range to the starting point
    $oItem = _OL_ItemCreate($oOutlook, $olAppointmentItem, "*\Outlook-UDF-Test\TargetFolder\Calendar", "", "Subject=TestSubject", "Start=" & _NowCalc(), "End=" & _DateAdd("h", 3, _NowCalc()), _
    "Location=Building A, Room 10", "RequiredAttendees=" & $oOutlook.GetNameSpace("MAPI").CurrentUser.Name)
    MsgBox(0, "", "$oItem: " & @error & "-" & IsObj($oItem))
    Global $oDoc = $oItem.GetInspector.WordEditor
    MsgBox(0, "", "$oDoc: " & @error & "-" & IsObj($oDoc) & "-" & $oItem.GetInspector.EditorType)
    Global $oRange = $oDoc.Range
    MsgBox(0, "", "$oRange: " & @error & "-" & IsObj($oRange))
    $oRange.Collapse($wdCollapseStart)
    MsgBox(0, "", "Collapse: " & @error)
    $oRange.InsertBefore("Inserted text at the start! ")
    MsgBox(0, "", "InsertBefore: " & @error)
    $oItem.Display()
    MsgBox(0, "", "Display: " & @error)
    _OL_Close($oOutlook)

    [/autoit]