Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Outlook 2000 1

Status
Not open for further replies.

FateFirst

Programmer
Apr 15, 2002
212
GB
Just wondering if anyone knows where I can get some example code or snippets which can take any mail item in a chosen folder and save it out as a text filename which is taken from a number that increments up by 1 each time.

I did write a script but it was very poor and couldnt keep up with the number of emails that came into the inbox, plus my text filename naming structure consisted of date() & time().

Any ideas would be very much appreciated!

Thanks guys! - FateFirst
 
Sure.. Try This:

Code:
Public Function DoExport()

    On Local Error Resume Next
    Dim oNS as NameSpace
    Set oNS = ThisOutlookSession.GetNamespace("MAPI")

    Dim MyMailbox as MAPIFolder
    Dim MyInbox as MAPIFolder
    Dim i as Integer

    For i = 1 to oNS.Folders.Count
        If InStr(oNS.Folders.Item(i).Name, &quot;Mailbox&quot;) <> 0 Then
            Set MyMailbox = oNS.Folders.Item(i)
            Set MyInbox = MyMailbox.Folders.Item(&quot;Inbox&quot;)
            Exit For
        End If
    Next i


    Dim oItem as MailItem
    Dim sFileName as String
    
    sFileName = &quot;c:\MyMails\MyMail&quot;

    For i = 1 To MyInbox.Items.Count
        Set oItem = MyInbox.Items.Item(i)
        Open sFileName & i & &quot;.txt&quot; For Output As #1
        Print #1, oItem.Body
        Close #1
    Next i

End Sub


Just wrote this up.. It worked without a problem for me at least.. s-)

--NipsMG
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top