P
Peter van den Hooff
Hi
As experienced VBA-programmer in ms-access I try to do something in
outlook but do not exactly know the right approach.
Situation: outlook 2003 and exchange and ms-access
Objectives:
1) create structure public folders as windows folders ( done = OK)
2) get mail content in ms-access tables (linked tables to exchange/
mapilevel) (done=OK)
3) save attachments as in created windows folders ( done=OK)
4) save items as *.MSG (?? works only certain mails, reason
unknown ???)
The following code is from line XX in a recursive folders in folders
enumeration:
? 1 : what is the difference between olMailItem and olPostItem (Said
before access programmer, not outlook
? 2 : why can't i set MyOutlookMailItem = objMapiSubFolder.Items(i)
but do I have to use
MyUndefindeObject = objMapiSubFolder.Items(i)
Advice is appreciated (please don't bother for the dutch name in the
code:
THANKS Peter van den Hooff
'----------------------------------------------------------------------------------------------------------------------------
onwards line XX in ap_FoldersInFolder objMapiSubFolder
----
----
----
ap_LogFolderStructuur nivo, prepad, objMapiSubFolder.Name,
objMapiSubFolder.DefaultItemType
prepad = prepad & "\" & objMapiSubFolder.Name
'-- mkdir to save attachments
ap_maakpad prepad, "C:\"
If objMapiSubFolder.DefaultItemType = 6 And volgnr0 = 1
(MAPIlevel0 public folders) Then
i = objMapiSubFolder.Items.Count
If i > 0 Then
Teller = Teller + 1
For i = 1 To objMapiSubFolder.Items.Count
'-- objItem = object,
'-- objItem = OUTLOOK.MAILITEM does not work
Set objItem = objMapiSubFolder.Items(i)
sGUID = objItem.EntryID
j = objItem.Attachments.Count
If j > 0 Then
For j = 1 To objItem.Attachments.Count
Set myAttachment =
objItem.Attachments.Item(j)
Set o = myAttachment.Parent
If o.Class = olMail Then
Set myMailItem = o
On Error GoTo FoutBijSaveAs
'-- WORKS ONLY FOR ABOU 20% OF THE
MAILS ?????????????????????????
myMailItem.SaveAs "c:\" & prepad &
"\" & DatumTijdMail & "_" & myMailItem.SenderEmailAddress & ".msg",
olMSG
On Error GoTo Foutafhandeling
Set myMailItem = Nothing
End If
myAttachment.SaveAsFile "c:\" & prepad &
"\" & myAttachment.FileName
sSQL = "INSERT INTO tbl_attachments " & _
"([EntryID],[folder],[file],
[datumtijdmail]) " & _
" values (""" & sGUID & """,""" & prepad &
""",""" & myAttachment.FileName & """,""" & DatumTijdMail & """)"
CurrentDb.Execute sSQL
SysCmd acSysCmdSetStatus, "c:\" & prepad &
"\" & myAttachment.FileName
Next j
End If
Next i
End If
End If
ap_FoldersInFolder objMapiSubFolder
Next objMapiSubFolder
As experienced VBA-programmer in ms-access I try to do something in
outlook but do not exactly know the right approach.
Situation: outlook 2003 and exchange and ms-access
Objectives:
1) create structure public folders as windows folders ( done = OK)
2) get mail content in ms-access tables (linked tables to exchange/
mapilevel) (done=OK)
3) save attachments as in created windows folders ( done=OK)
4) save items as *.MSG (?? works only certain mails, reason
unknown ???)
From within ms-access I enumerate recursive folders in folders.
The following code is from line XX in a recursive folders in folders
enumeration:
? 1 : what is the difference between olMailItem and olPostItem (Said
before access programmer, not outlook
? 2 : why can't i set MyOutlookMailItem = objMapiSubFolder.Items(i)
but do I have to use
MyUndefindeObject = objMapiSubFolder.Items(i)
Advice is appreciated (please don't bother for the dutch name in the
code:
THANKS Peter van den Hooff
'----------------------------------------------------------------------------------------------------------------------------
onwards line XX in ap_FoldersInFolder objMapiSubFolder
----
----
----
ap_LogFolderStructuur nivo, prepad, objMapiSubFolder.Name,
objMapiSubFolder.DefaultItemType
prepad = prepad & "\" & objMapiSubFolder.Name
'-- mkdir to save attachments
ap_maakpad prepad, "C:\"
If objMapiSubFolder.DefaultItemType = 6 And volgnr0 = 1
(MAPIlevel0 public folders) Then
i = objMapiSubFolder.Items.Count
If i > 0 Then
Teller = Teller + 1
For i = 1 To objMapiSubFolder.Items.Count
'-- objItem = object,
'-- objItem = OUTLOOK.MAILITEM does not work
Set objItem = objMapiSubFolder.Items(i)
sGUID = objItem.EntryID
j = objItem.Attachments.Count
If j > 0 Then
For j = 1 To objItem.Attachments.Count
Set myAttachment =
objItem.Attachments.Item(j)
Set o = myAttachment.Parent
If o.Class = olMail Then
Set myMailItem = o
On Error GoTo FoutBijSaveAs
'-- WORKS ONLY FOR ABOU 20% OF THE
MAILS ?????????????????????????
myMailItem.SaveAs "c:\" & prepad &
"\" & DatumTijdMail & "_" & myMailItem.SenderEmailAddress & ".msg",
olMSG
On Error GoTo Foutafhandeling
Set myMailItem = Nothing
End If
myAttachment.SaveAsFile "c:\" & prepad &
"\" & myAttachment.FileName
sSQL = "INSERT INTO tbl_attachments " & _
"([EntryID],[folder],[file],
[datumtijdmail]) " & _
" values (""" & sGUID & """,""" & prepad &
""",""" & myAttachment.FileName & """,""" & DatumTijdMail & """)"
CurrentDb.Execute sSQL
SysCmd acSysCmdSetStatus, "c:\" & prepad &
"\" & myAttachment.FileName
Next j
End If
Next i
End If
End If
ap_FoldersInFolder objMapiSubFolder
Next objMapiSubFolder