Outlook Termine auslesen und erstellen (PureDisphelper?)

Für allgemeine Fragen zur Programmierung mit PureBasic.
ndklinux
Beiträge: 5
Registriert: 09.05.2007 16:56
Wohnort: Esch/Alzette

Outlook Termine auslesen und erstellen (PureDisphelper?)

Beitrag von ndklinux »

Hallo an alle,


Hat vielleicht jemand eine Idee wie man bei Outlook (2003) Termine über PureBasic auslesen und erstellen kann.

Habe schon das ganze Internet durchgegooglet aber leider nichts erreicht ;(


Vielen Dank
Benutzeravatar
Kiffi
Beiträge: 10714
Registriert: 08.09.2004 08:21
Wohnort: Amphibios 9

Re: Outlook Termine auslesen und erstellen (PureDisphelper?)

Beitrag von Kiffi »

ndklinux hat geschrieben:Hat vielleicht jemand eine Idee wie man bei Outlook (2003) Termine über PureBasic auslesen und erstellen kann.
ich selber nutze Outlook nicht und meines Wissens gibt es noch keinen
entsprechenden PB-Code hierzu.

Wenn Du allerdings einen Code in VB(S) zum Thema findest (und ich
vermute stark, dass es davon etliche gibt): Den kann man relativ leicht und
fast eins zu eins in die PureDispHelper-Syntax umsetzen.

Also: Noch mal an die Google-Maschine setzen, fleissig suchen und wenn Du
fündig geworden bist, den Code hier posten.

Grüße .... Kiffi
a²+b²=mc²
ndklinux
Beiträge: 5
Registriert: 09.05.2007 16:56
Wohnort: Esch/Alzette

Beitrag von ndklinux »

Hallo,

Danke für die Antwort. Ich habe mal dies hier zum erstellen eines Termins gefunden. Beim auslesen der Termine bin ich noch nicht weiter gekommen.

Code: Alles auswählen

 ' Create a new appointment.
   Dim olAppt As Outlook.AppointmentItem
   Set olAppt = olApp.CreateItem(olAppointmentItem)
    
 ' Set start time for 2-minutes from now...
   olAppt.Start = Now() + (2# / 24# / 60#)
    
 ' Setup other appointment information...
   With olAppt
      .Duration = 60
      .Subject = "Meeting to discuss plans..."
      .Body = "Meeting with " & olItem.FullName & " to discuss plans."
      .Location = "Home Office"
      .ReminderMinutesBeforeStart = 1
      .ReminderSet = True
   End With
    
 ' Save Appointment...
   olAppt.Save
Alles in Visual Basic, kann man das nach PB übersetzen?
Benutzeravatar
Kiffi
Beiträge: 10714
Registriert: 08.09.2004 08:21
Wohnort: Amphibios 9

Beitrag von Kiffi »

ndklinux, Du Schlingel! Du solltest doch einen funktionierenden
Code posten ;-)

Code: Alles auswählen

EnableExplicit

Define.l olApp     ; Application
Define.l olAppt    ; AppointmentItem
Define.d StartDate ; Startdatum als Double!

#olAppointmentItem = 1
    
olApp = dhCreateObject("Outlook.Application")

If olApp
  
  dhGetValue("%o", @olAppt, olApp, ".CreateItem(%d)", #olAppointmentItem)
  
  If olAppt
    
    ; Set start time for 2-minutes from now...
    StartDate = AddDate(Date(), #PB_Date_Minute, 2)
    StartDate = StartDate / 86400.0 + 25569.0
    
    dhPutValue(olAppt, ".Start = %D", @StartDate)
    
    ; Setup other appointment information...
    dhPutValue(olAppt, ".Duration                   = %d", 60)
    dhPutValue(olAppt, ".Subject                    = %T", @"Remember...")
    dhPutValue(olAppt, ".Body                       = %T", @"PureBasic: Feel the ..Pure.. Power :-)")
    dhPutValue(olAppt, ".Location                   = %T", @"PureBoard")
    dhPutValue(olAppt, ".ReminderMinutesBeforeStart = %d", 1)
    dhPutValue(olAppt, ".ReminderSet                = %d", #True)
    
    ; Save Appointment...
    dhCallMethod(olAppt, ".Save")
    
    dhReleaseObject(olAppt)
    
  Else
    
    Debug "!olAppt"
    
  EndIf
  
  dhReleaseObject(olApp)
  
Else
  
  Debug "!olApp"
  
EndIf
Schau Dir den Code mal in Ruhe an und vergleiche ihn mit dem VB-Code.
Du wirst eine Menge an Parallelen erkennen und sehen, dass die
Umsetzung zwischen den beiden Programmiersprachen gar nicht so
schwierig ist. :-)

Grüße ... Kiffi
a²+b²=mc²
marco2007
Beiträge: 906
Registriert: 26.10.2006 13:19
Kontaktdaten:

Beitrag von marco2007 »

Hi,

das sollte mal weiterhelfen:

Code: Alles auswählen

Procedure.s VBScriptCode()
	Protected VBS$
  	VBS$ + "Const cal = 9" + #CRLF$
  	VBS$ + "Set objOutlook = CreateObject(" + Chr(34) + "Outlook.Application" + Chr(34) + ")" + #CRLF$
  	VBS$ + "Set objNamespace = objOutlook.GetNamespace(" + Chr(34) + "MAPI" + Chr(34) + ")" + #CRLF$
   	VBS$ + "Set objFolder = objNamespace.GetDefaultFolder(cal)" + #CRLF$
   	VBS$ + "Set colItems = objFolder.Items" + #CRLF$
   	VBS$ + "Anzahl =  colItems.Count" + #CRLF$
   	VBS$ + "For Each objItem in colItems" + #CRLF$
  	VBS$ + "name = name & objItem & vbCRLF & objItem.start & vbCRLF & objItem.End & vbCRLF  & objItem.body & vbCRLF & vbCRLF"+ #CRLF$
  	VBS$ + "Next" + #CRLF$

	ProcedureReturn VBS$

EndProcedure

SCtr_SetLanguage("VBScript")
SCtr_AddCode(VBScriptCode())
MessageRequester(SCtr_EvalStr("Anzahl") + " Einträge",  SCtr_EvalStr("name"))


Für PureDisphelper mußt Du es jedoch noch ein bißchen anpassen.
Ich habe hier das ScriptControl von TS-Soft & MK-Soft verwendet.

http://www.purebasic.fr/german/viewtopic.php?t=8761

lg
Marco
Zuletzt geändert von marco2007 am 20.06.2008 21:07, insgesamt 1-mal geändert.
Windows 11 - PB 6.03 x64
_________________________________
marco2007
Beiträge: 906
Registriert: 26.10.2006 13:19
Kontaktdaten:

Beitrag von marco2007 »

...und da ich schon auf http://support.microsoft.com/kb/201095/de war. Folgender VBS-Code fügt Outlook einen PureBasic-Button hinzu:

Code: Alles auswählen

; Outlook muss geöffnet sein! 

Procedure.s VBS_AddButton()

	Protected VBS$
	VBS$ + "Set ol = CreateObject(" + Chr(34) + "Outlook.Application" + Chr(34) + ")" + #CRLF$
	VBS$ + "Set objBar = ol.ActiveExplorer.CommandBars.Item(" + Chr(34) + "Standard" + Chr(34) + ")" + #CRLF$
	VBS$ + "Set objButton = objBar.Controls.Add(, , , , True)" + #CRLF$
 	VBS$ + "With objButton" + #CRLF$
	VBS$ + ".caption = " + Chr(34) + "PureBasic"+ Chr(34) + #CRLF$
	VBS$ + ".Tooltiptext = " + Chr(34) + "Feel the Pure Power" + Chr(34) + #CRLF$
	VBS$ + ".Visible = True " + #CRLF$
  VBS$ + "End With" + #CRLF$
	ProcedureReturn VBS$

EndProcedure

SCtr_SetLanguage("VBScript")
SCtr_AddCode(VBS_AddButton()) 


lg
Marco
Windows 11 - PB 6.03 x64
_________________________________
ndklinux
Beiträge: 5
Registriert: 09.05.2007 16:56
Wohnort: Esch/Alzette

Beitrag von ndklinux »

Hi,

Vielen Dank das mit dem erstellen der Termine klappt wunderbar.
Zum Auslesen von Outlook Terminen habe ich folgenden Code in PHp gefunden. Werde versuchen den in PB umzusetzen. Poste ihn dann hier falls mal jemand so etwas braucht.

Code: Alles auswählen

<?

$outlook = new COM("outlook.application") or die("Konnte Outlook nicht instantiieren");
print "Outlook Version {$outlook->Version}, Product-Code {$outlook->ProductCode}";
$myNameSpace = $outlook->GetNamespace("MAPI");
$myNameSpace->Logon('Outlook');
$myFolder = $myNameSpace->GetDefaultFolder(9);
$colItems = $myFolder->Items;
foreach($colItems as $item) {
  echo "Start: ".$item->Start."\n";
  echo "Ende: ".$item->End."\n";
  echo "Location: ".$item->Location."\n";
  echo "Subject: ".$item->Subject."\n";
  echo "Sensitivity: ".$item->Sensitivity."\n";
  echo "Body: ".$item->Body."\n";
  echo "LastModificationTime: ".$item->LastModificationTime."\n\n";
}
  
?>
marco2007
Beiträge: 906
Registriert: 26.10.2006 13:19
Kontaktdaten:

Beitrag von marco2007 »

...Du kannst doch meinen ersten Code verwenden...der ist bereits umgesetzt und funktioniert.

Okay, hier das selbe noch mal mit PureDisphelper:

Code: Alles auswählen

EnableExplicit
Procedure.s Termine()
   Protected VBS$ 
     VBS$ + "Const cal = 9" + #CRLF$ 
     VBS$ + "Set objOutlook = CreateObject(" + Chr(34) + "Outlook.Application" + Chr(34) + ")" + #CRLF$ 
     VBS$ + "Set objNamespace = objOutlook.GetNamespace(" + Chr(34) + "MAPI" + Chr(34) + ")" + #CRLF$ 
      VBS$ + "Set objFolder = objNamespace.GetDefaultFolder(cal)" + #CRLF$ 
      VBS$ + "Set colItems = objFolder.Items" + #CRLF$ 
      VBS$ + "Anzahl =  colItems.Count" + #CRLF$ 
      VBS$ + "For Each objItem in colItems" + #CRLF$ 
     VBS$ + "name = name & objItem & vbCRLF & objItem.start & vbCRLF & objItem.End & vbCRLF  & objItem.body & vbCRLF & vbCRLF"+ #CRLF$ 
     VBS$ + "Next" + #CRLF$ 
   ProcedureReturn VBS$ 
EndProcedure

dhToggleExceptions(#True)

Define.l Result, Anzahl, obj = dhCreateObject("MSScriptControl.ScriptControl")
Define.s Script

If obj
  dhPutValue(obj, "Language = %T", @"VBScript")
  Script = Termine()
  dhCallMethod(obj, "AddCode(%T)", @Script)
  dhGetValue("%T", @Result, obj, "Eval(%T)", @"name")
  dhGetValue("%T", @Anzahl, obj, "Eval(%T)", @"Anzahl")
  MessageRequester(PeekS(Anzahl)+ " Termine", PeekS(Result))
EndIf


Das hier ist nicht schlecht: www.easyon.at/support/prog/vb/outlook/files/vbso.pdf

lg
Marco
Windows 11 - PB 6.03 x64
_________________________________
Antworten