Export Calendar to XML

P

pmo

Hallo Leute.

Ich möchte mit folgendem Code alle CalendarItems in ein XML-File
schreiben. Das klappt eigentlich ganz gut. Aber bei einem Serientermin
wird nur einmal exportiert. Das heisst,
wenn ich einen neuen Serientermin erstelle, welcher beginnend am 24.Mai
2006 wöchentlich statt findet, bekomme ich im XML-File nur den Eintrag
vom 24.Mai 2006. Wie kann ich
die 'SubItems' dieser TeminSerie auch exportieren?

Hier mein Code:

Dim goNS As NameSpace
Dim goCal As MAPIFolder
Dim goCalItem As AppointmentItem

Dim goFSO As FileSystemObject
Dim gsXML As String
Dim giCounter As Integer

Sub Main()

Set goFSO = CreateObject("Scripting.FileSystemObject")
gsXML = Environ("USERPROFILE") & "\Desktop\Events.xml"
giCounter = 0

If goFSO.FileExists(gsXML) Then
If MsgBox("Die Datei '" & gsXML & "' existiert bereits." &
vbNewLine & _
"Soll Sie überschrieben werden?", vbQuestion +
vbYesNo, "Datei überschreiben?") = vbYes Then
goFSO.DeleteFile gsXML, True
goFSO.CreateTextFile gsXML, True
Else
Exit Sub
End If
Else
goFSO.CreateTextFile gsXML, True
End If

Open gsXML For Append As #10
Print #10, "<?xml version=" & Chr(34) & "1.0" & Chr(34) & "?>"
Print #10, "<macromedia_resources xmlns:macromedia_resources="
& Chr(34) &
"http://www.macromedia.com/devnet/resources/macromedia_resources.dtd" &
Chr(34) & ">"
Close #10

Set goNS = Outlook.Application.GetNamespace("MAPI")
Set goCal = goNS.GetDefaultFolder(olFolderCalendar)


For Each goCalItem In goCal.Items
If goCalItem.IsRecurring = True Then
'Item ist ein SerienTermin
Else
'Item ist kein SerienTermin
ExportToXML goCalItem.Subject, Format(goCalItem.Start,
"d.m.yyyy"), Format(goCalItem.Start, "hh:nn"), goCalItem.Body
End If
Next goCalItem


Open gsXML For Append As #11
Print #11, "</macromedia_resources>"
Close #11

Set goFSO = Nothing
Set goNS = Nothing
Set goCal = Nothing
Set goCalItem = Nothing

MsgBox "Export abgeschlossen"

End Sub

Sub ExportToXML(lsSubject As String, lsDate As String, lsTime As
String, lsMemo As String)

Open gsXML For Append As #1
If giCounter = 0 Then
Print #1, vbTab & "<resource type=" & Chr(34) & "Column" &
Chr(34) & ">"
Else
Print #1, vbTab & "<resource type=" & Chr(34) & "Article" &
Chr(34) & ">"
End If

Print #1, vbTab & vbTab & "<date>" & Format(lsDate, "d.m.yyyy")
& "</date>"
Print #1, vbTab & vbTab & "<time>" & Format(lsTime, "hh:nn") &
"</time>"
Print #1, vbTab & vbTab & "<title>" & lsSubject & "</title>"
Print #1, vbTab & vbTab & "<desc>" & lsMemo & "</desc>"

Print #1, vbTab & "</resource>"
Close #1

giCounter = giCounter + 1

End Sub

Ich bin euch für jede Hilfe dankbar.

Gruss pmo
 
M

Michael Bauer

Am 19 May 2006 22:38:35 -0700 schrieb pmo:

Before the loop please set the Item´s property IncludeRecurrences = True.

BTW: This is an English speaking group. You´d increase your chance for
answers dramatically by speaking English, too.
 
P

pmo

Hi Michael.

Sorry, but my written English is very bad... so i think it is better
that i use German.

I have implemted the ItemsProperty, but i does still not work.

Here is my Code:

Set goCal = goNS.GetDefaultFolder(olFolderCalendar)
Set goCalItems = goCal.Items

goCalItems.IncludeRecurrences = True

For Each goCalItem In goCalItems
ExportToXML goCalItem.Subject, Format(goCalItem.Start,
"d.m.yyyy"), Format(goCalItem.Start, "hh:nn"), goCalItem.Body
Next goCalItem

Why ???

Best regards

pmo
 
M

Michael Bauer

Am 20 May 2006 00:35:58 -0700 schrieb pmo:

As far as I can tell, your written English good. Anyway, if you rather like
to discuss in German then please try microsoft.public.de.outlook
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top