Ik heb een applicatie gemaakt die agenda items kan toevoegen aan Outlook. Nu zit met het volgende probleem. Als ik agenda items toevoeg terwijl Outlook gesloten is en ik start Outlook na het toevoegen van agenda items opnieuw op, geeft outlook een error:
"Client bewerking is mislukt."
Als ik Outlook niet sluit tijdens het inplannen gaat alles goed. Zo langzamerhand zit ik aan het einde van mijn geduld. Meerdere maanden werk al inmiddels en altijd nog niet stabiel..
Als iemand enig idee/oplossing heeft of mijn code zou willen testen zou ik daar zeer blij van worden! Alle suggesties zijn welkom.
Stappenplan:
- Outlook sluiten (Proces mag niet meer in geheugen staan.
- Applicatie opstarten.
- Items toevoegen.
- Outlook starten * Foutmelding *
Dit is mijn toevoeg functie:
Dit is mijn connect en disconnect functie:
In mijn geval ziet de aanroepende functie er zo uit:
'Jacob Mesu' vervangen door de gebruikersnaam in Outlook
Hier is de complete source:
http://www.mesu.nl/tmp/uoutlooksync.pas © <-
De oplossing is om Outlook.exe uit de proceslijst te verwijderen en dan kan ik Outlook weer gewoon opstarten.
"Client bewerking is mislukt."
Als ik Outlook niet sluit tijdens het inplannen gaat alles goed. Zo langzamerhand zit ik aan het einde van mijn geduld. Meerdere maanden werk al inmiddels en altijd nog niet stabiel..
Stappenplan:
- Outlook sluiten (Proces mag niet meer in geheugen staan.
- Applicatie opstarten.
- Items toevoegen.
- Outlook starten * Foutmelding *
Dit is mijn toevoeg functie:
Delphi:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
| { Insert an appointment into the calendar of some user. If the user is the local User then opens the default folders, otherwise open the shared folder of the user The functions raise an exception when the Outlook folder can't be accessed. } function TOutlookSync.InsertAppToOtherUser( AGebruikersnaam: String; AOnderwerp: String; AAgendaTekst: WideString; ALocatie : String; AStartDatum: Integer; AStartTijd: Integer; AEindDatum: Integer; AEindTijd: Integer; ReminderMin: Integer; APrioriteit: Integer; AStatus: Integer; ADisplay: Boolean): string; var intCalItem : OleVariant; intPubFolder : OleVariant; intInspector : OleVariant; begin try try Result := ''; if AGebruikersnaam <> FNameSpace.CurrentUser.Name then intPubFolder := FNameSpace.GetSharedDefaultFolder(FNameSpace.CreateRecipient(AGebruikersnaam), olFolderCalendar) else intPubFolder := FNameSpace.GetDefaultFolder(olFolderCalendar); intCalItem := intPubFolder.Items.Add; intCalItem.Subject := AOnderwerp; intCalItem.Body := AAgendaTekst; intCalItem.Start := AMFIntDateTimeToDateTime(AStartDatum, AStartTijd); intCalItem.End := AMFIntDateTimeToDateTime(AEindDatum, AEindTijd); intCalItem.Location := ALocatie; intCalItem.ConferenceServerPassword := FNameSpace.CurrentUser.Name; case APrioriteit of 0: intCalItem.Importance := olImportanceLow; 1: intCalItem.Importance := olImportanceNormal; 2: intCalItem.Importance := olImportanceHigh; end; case AStatus of 0: intCalItem.BusyStatus := olFree; 1: intCalItem.BusyStatus := olTentative; 2: intCalItem.BusyStatus := olBusy; end; // Aanmaken inspector voor openen item if ADisplay then begin intCalItem.Save; // give him some time Sleep(200); // Make explorer active, never open inspector without selecting an // explorer intPubFolder.GetExplorer; intInspector := FApplication.Inspectors.Add(intCalItem); intInspector.Display(true); //intInspector.Activate; end else intCalItem.Save; Result := intCalItem.EntryId; except raise ExceptClass.Create('Kan het item niet opslaan in Outlook'); end; finally //intCalItem := Unassigned; //intPubFolder := Unassigned; //intInspector := Unassigned; end; end; |
Dit is mijn connect en disconnect functie:
Delphi:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
| { Connect to outlook } procedure TOutlookSync.Connect(); begin try FApplication := Unassigned; try FApplication := GetActiveOleObject('Outlook.Application'); if (FApplication = Unassigned) then FApplication := CreateOleObject('Outlook.Application'); except FApplication := CreateOleObject('Outlook.Application'); end; FNameSpace := FApplication.getNameSpace( 'MAPI' ); FSession := CreateOleObject('MAPI.Session'); FSession.Logon('Outlook','',false,true); FConnected := true; except FApplication := Unassigned; FNamespace := Unassigned; FConnected := false; raise ExceptClass.Create('Kan geen verbinding krijgen met Outlook'); end; end; { Disconnect from Outlook and release the obtained COM objects } procedure TOutlookSync.Disconnect(); begin FNameSpace.LogOff; FSession.LogOff; FApplication := Unassigned; end; |
In mijn geval ziet de aanroepende functie er zo uit:
Delphi:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
| procedure TfrmMain.Button2Click(Sender: TObject); begin Outlook.Connect; Outlook.InsertAppToOtherUser( 'Jacob Mesu', '[TN 1234]', 'Dit is de tekst', 'herr', 20070316, 140000, 20070316, 200000, 10, 0, 0, false ); Outlook.Disconnect; end; |
'Jacob Mesu' vervangen door de gebruikersnaam in Outlook
Hier is de complete source:
http://www.mesu.nl/tmp/uoutlooksync.pas © <-
De oplossing is om Outlook.exe uit de proceslijst te verwijderen en dan kan ik Outlook weer gewoon opstarten.
http://hawvie.deviantart.com/