A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

problems with .SaveAs during recursive enumeration in public folders



 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old April 3rd 07, 06:33 PM posted to microsoft.public.outlook.program_vba
Peter van den Hooff
external usenet poster
 
Posts: 2
Default problems with .SaveAs during recursive enumeration in public folders

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 ???)

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

 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
OL2k3 Automatically Adding Public Folders to 'Favorite Folders' list in Mail Ben Outlook - General Queries 0 October 4th 06 04:19 PM
How do I configure Public Folders to be default contact folders? RobinBaral Outlook - Using Contacts 2 September 27th 06 04:12 PM
Is there a way to display Public Folders in the All Mail Folders view? Outlook2003 Cappy Outlook - General Queries 1 July 20th 06 02:20 AM
Is there a way to display Public Folders in the All Mail Folders view? Outlook2003 Cappy Outlook - Installation 1 July 20th 06 02:20 AM
Problems with Public Calendar CalendarGirl Outlook - Calandaring 0 March 7th 06 12:51 AM


All times are GMT +1. The time now is 12:36 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.