Home All Groups Group Topic Archive Search About

Move emails (.msg files) between an Outlook inbox and a file direc

Author
6 May 2006 12:16 AM
tom north
What I am after would be a VB script perhaps using CDO to access the inbox of
a mailbox, and push or pull messages in or out to a flat file directory on
disk
--
Tom North

Author
6 May 2006 2:02 AM
vbnetdev
Imports System
Imports System.Reflection
Imports Outlook = Microsoft.Office.Interop.Outlook

Namespace PACKERSROCK
Public Class VIKINGSSUCK



        Public Shared Function Main() As Integer
            Try

                Dim oApp As Microsoft.Office.Interop.Outlook.Application =
New Outlook.Application()

                Dim oNS As Outlook.NameSpace = oApp.GetNamespace("mapi")

                oNS.Logon(Missing.Value, Missing.Value, False, True)


                Dim oInbox As Outlook.MAPIFolder =
oNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox)


                Dim oItems As Outlook.Items = oInbox.Items

                Dim oMsg As Outlook.MailItem = CType(oItems.GetFirst(),
Outlook.MailItem)

                'Check for attachments.
                Dim AttachCnt As Integer = oMsg.Attachments.Count
                Debug.WriteLine("Attachments: " + AttachCnt.ToString())

                If AttachCnt > 0 Then
                    Dim i As Integer
                    For i = 1 To AttachCnt Step i + 1
                        Debug.WriteLine(i.ToString() + "-" +
oMsg.Attachments(i).DisplayName)
                    Next
                End If

                oMsg.SaveAs("C:\TESTMSG.DOC", Nothing)
                oNS.Logoff()


                oMsg = Nothing
                oItems = Nothing
                oInbox = Nothing
                oNS = Nothing
                oApp = Nothing
                'End Try

                'Error handler.
            Catch e As Exception
                Debug.WriteLine("{0} Exception caught: ", e.ToString)

                ' Return value.
                Return 0
            End Try


        End Function
    End Class
End Namespace

--
Get a powerful web, database, application, and email hosting with KJM
Solutions
http://www.kjmsolutions.com



Show quoteHide quote
"tom north" <tomno***@discussions.microsoft.com> wrote in message
news:BBD4246B-5D53-4231-A05E-511D09651B2D@microsoft.com...
> What I am after would be a VB script perhaps using CDO to access the inbox
> of
> a mailbox, and push or pull messages in or out to a flat file directory on
> disk
> --
> Tom North