Access generic outlook email account...

lidds

Well-known member
Joined
Oct 19, 2004
Messages
122
Programming Experience
Beginner
I need a bit of help and guidance as this is a new area for me. I have searched on the web for quite sometime, but I can only find examples on how to link into the users outlook account on their machine.

What I want is my clients to create a gerneic email account e.g. everyone@mycompany.com on their outlook exchange server. Then my application that will be run on users machine to access the inbox of the generic email account. I do not want to send email through this account just read the emails received.

My question is whether this is possible and if so if someone could provide example code or what I should be searching for in google.

Thanks for your help

Simon
 
Extracting mails and attachments from outlook 2003 in vb.net - CodeProject

The above code shows looping through the messages in a specific folder of a user.

Programming Microsoft Outlook with Visual Studio .NET

The above link is to a large reference to do a plethora of activities in outlook and should be a good guide to find what you are specifically trying.

This all becomes significantly simpler if you are using an exchange server and you can do a lot of the CDO objects.

Here is some code that lists the users within a distribution list:

VB.NET:
Imports System.Reflection

Module Module1

    Sub Main()
        ' Create Outlook application.
        Dim oApp As Outlook.Application = New Outlook.Application()

        ' Get Mapi NameSpace and Logon.
        Dim oNS As Outlook.NameSpace = oApp.GetNamespace("mapi")
        oNS.Logon("YourValidProfile", Missing.Value, False, True) ' TODO:
      
        ' Get Global Address List.
        Dim oDLs As Outlook.AddressLists = oNS.AddressLists
        Dim oGal As Outlook.AddressList = oDLs.Item("Global Address List")
        Console.WriteLine(oGal.Name)

        ' Get a specific distribution list.
        ' TODO: Replace the distribution list with a distribution list that is available to you.
        Dim sDL As String = "TestDL"
        Dim oEntries As Outlook.AddressEntries = oGal.AddressEntries
        ' No filter available to AddressEntries
        Dim oDL As Outlook.AddressEntry = oEntries.Item(sDL)

        Console.WriteLine(oDL.Name)
        Console.WriteLine(oDL.Address)
        Console.WriteLine(oDL.Manager)

        ' Get all of the members of the distribution list.
        oEntries = oDL.Members
        Dim oEntry As Outlook.AddressEntry
        Dim i As Integer

        For i = 1 To oEntries.Count
            oEntry = oEntries.Item(i)
            Console.WriteLine(oEntry.Name)

            ' Display the Details dialog box.
            'oDL.Details(Missing.Value)
        Next

        ' Log off.
        oNS.Logoff()

        ' Clean up.
        oApp = Nothing
        oNS = Nothing
        oDLs = Nothing
        oGal = Nothing
        oEntries = Nothing
        oEntry = Nothing
    End Sub

End Module

Here is some code to retrieve the unread messages from an inbox:

VB.NET:
Imports System.Reflection

Module Module1

    Sub Main()
       ' Create Outlook application.
        Dim oApp As Outlook.Application = New Outlook.Application()
        
        ' Get Mapi NameSpace.
        Dim oNS As Outlook.NameSpace = oApp.GetNamespace("mapi")
        oNS.Logon("YourValidProfile", Missing.Value, False, True) ' TODO:

        ' Get Messages collection of Inbox.
        Dim oInbox As Outlook.MAPIFolder = oNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox)
        Dim oItems As Outlook.Items = oInbox.Items
        Console.WriteLine("Total : " & oItems.Count)

        ' Get unread e-mail messages.
        oItems = oItems.Restrict("[Unread] = true")
        Console.WriteLine("Total Unread : " & oItems.Count)

        ' Loop each unread message.
        Dim oMsg As Outlook.MailItem
        Dim i As Integer

        For i = 1 To oItems.Count
            oMsg = oItems.Item(i)

            Console.WriteLine(i)
            Console.WriteLine(oMsg.SenderName)
            Console.WriteLine(oMsg.Subject)
            Console.WriteLine(oMsg.ReceivedTime)
            Console.WriteLine(oMsg.Body)
            Console.WriteLine("---------------------------")
        Next

        ' Log off.
        oNS.Logoff()

        ' Clean up.
        oApp = Nothing
        oNS = Nothing
        oItems = Nothing
        oMsg = Nothing
    End Sub

End Module

Both code samples were taken from the Microsoft website.
 
Back
Top