Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Excel97 macro to archive Outlook mailbox
I need a macro that will be able to read email from Outlook and create an
archive PST file according to certain date criteria. I have a bit of code that will access my inbox and tell me the subject headers of the mails within certain dates. However, I need to access the inbox of another mailbox that I have access to and does not contain my default inbox. So first question is: How do I get the macro to access the inbox of another Mailbox? Secondly, what command do I need to use to make the PST file? I'm limited to Excel97 and Outlook97. Here is my function as it stands at the moment: Private Function ArchiveEmail(StartDate As Date, EndDate As Date) As Boolean Dim returnState As Boolean Dim olApp As Outlook.Application Dim olEmail As Outlook.MailItem Dim EmailItemCount As Integer Dim OLF As Outlook.MAPIFolder Dim subjectLog As String Dim em 'assume success returnState = True 'set the error trap On Error Resume Next 'GoTo Connect_Error Set olApp = GetObject("Outlook.Application") If Err < 0 Then 'outlook not running so start it Set olApp = CreateObject("outlook.application") End If Set OLF = GetObject("", "Outlook.Application").GetNamespace("MAPI").GetDef aultFolder(olFolderInbox) EmailItemCount = OLF.Items.Count subjectLog = "Email count: " & EmailItemCount Set olEmail = olApp.Item(olMailItem) For Each em In OLF.Items With em If .ReceivedTime <= StartDate _ And .ReceivedTime = EndDate _ Then subjectLog = subjectLog & vbCrLf & .Subject End If End With Next MsgBox subjectLog Archive_Exit: ArchiveEmail = returnState Exit Function Connect_Error: returnState = False MsgBox Err.Number & ": " & Err.Description, vbOKOnly + vbApplicationModal + vbCritical, "Archive Email" Resume Archive_Exit End Function ------- Cheers, Geo -- Quacking Eck! It's The Duck! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Auto Forward in Mailbox | Excel Discussion (Misc queries) | |||
UNDO in EXCEL97 macro | Excel Programming | |||
why doesn't excel97 winNT vba macro code work in excel2002 winXP??? | Excel Programming | |||
excel97: filtering out the zeros macro | Excel Programming | |||
Archive Macro | Excel Programming |