Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Beginning VB 6
Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old October 27th, 2004, 01:53 PM
Registered User
Join Date: Oct 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default outlook - vbscript Help please

Need help!!!!!

I am trying to pull only fields TO, SUBJECT AND SENT DATE from Microsoft Server folder from a particular subfolder and collect information onto access or excel or text.

I am asked to produce a report of all item sent in year 2004 and give a count of emails by month.

New at coding
Need help.

Can you please check the code and let me know where I went wrong?

Private Sub ProcessInbox_Click()
   '' Folder in Microsoft Exchange Server folder
    Dim oOutlookApp As Outlook.Application
    Dim oFolder1 As Outlook.MAPIFolder
    Dim oFolder2 As Outlook.MAPIFolder
    Dim oMsgItem As Outlook.MailItem
    Dim iMsgCount As Integer
    Dim strFolderName As String

    ' get reference to personal folder

    Set oOutlookApp = CreateObject("Outlook.Application")
    Set oFolder1 = Session.Folders("Personal Folders")
    Set oFolder2 = oFolder1.Folders("PMA")

   iMsgCount = 0

    For Each oMsgItem In oFolder2.Items
        With oMsgItem
            If .SenderName = "PMA" Or .SenderName = "PAM" Then
               If Date >= #1/1/2004# And Date <= #1/31/2004# Then
                    Debug.Print .To
                    Debug.Print .Subject
                    Debug.Print .Sent

                    iMsgCount = iMsgCount + 1
                    'save in an excel or text file
                    .SaveAs "c:\message.txt"

                End If
            End If
        End With
   Next oMsgItem

    Set oMsgItem = Nothing
    Set oFolder1 = Nothing
    Set oFolder2 = Nothing
    Set oOutlookApp = Nothing
End Sub

Thanks in advance



Similar Threads
Thread Thread Starter Forum Replies Last Post
Referencing Fields using VBScript in Outlook 2000 stelhead All Other Wrox Books 0 January 3rd, 2008 12:04 PM
VBScript junedali10 VB How-To 3 September 27th, 2006 03:06 PM
VBSCRIPT pantera710 Classic ASP Basics 3 September 11th, 2006 09:28 PM
Need Help in VBScript ragavendran31 Pro VB 6 0 April 19th, 2006 05:54 AM
IS it possible to call Outlook from VBScript? nfoliveira VBScript 1 March 19th, 2004 09:49 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.