Solved

how to read outlook emails using vb.net

Posted on 2014-09-26
9
1,135 Views
Last Modified: 2014-09-30
Hi, I need to read the emails from outlook. The code is giving me an error

        Dim objOL As Outlook.Application
        Dim objNS As Outlook.NameSpace
        Dim objFolder As Outlook.Folders
        Dim Item As Object
        'Dim myItems As Outlook.Items
        Dim x As Int16

        objOL = New Outlook.Application()
        objNS = objOL.GetNamespace("MAPI")

        Dim olfolder As Outlook.MAPIFolder
        If direction = "IN" Then
            olfolder = objOL.GetNamespace("Mapi").GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox)
        Else
            olfolder = objOL.GetNamespace("Mapi").GetDefaultFolder(Outlook.OlDefaultFolders.olFolderSentMail)
        End If

        myItems = olfolder.Items

It bombs in the ofolder.items giving an error :

Interface not registered (Exception from HRESULT: 0x80040155)

I appreciate your help experts. Thanks
0
Comment
Question by:fmichail
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 40347551
I prefer not use automation to read Excel. I use http://www.limilabs.com/mail
0
 

Author Comment

by:fmichail
ID: 40347702
Eric Moreau,
Thanks for the response, however, I am restricted to interface the application with outlook. Can mail.dll interface with outlook? Like list emails from outlook / send email through outlook / open and view outlook / retrieve the outlook currently selected email?

In fact I have little understanding of how emails are retreived, and saved in general. however, the component looks encouraging  if it interfaces with outlook.

Please reply. Thanks
0
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 500 total points
ID: 40347749
mail.dll is like connecting to your mail server to retrieve them, read, delete

if you would like to send email, you better just use the .Net framework system.net.mail (http://systemnetmail.com/)
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:fmichail
ID: 40348161
Thanks again Eric, the application is targeting a company which uses outlook for emails. Can mail.dll connect to where the emails of the users are (I do not know where outlook retrieves them from), and retrieve these emails even while outlook is working ... in other words, is there any setting (or coding) to tell mail.dll how retrieve the outlook emails for the current user... Sorry Eric, I do not know how outlook works... Please reply. when the mail.dll sends an email, will it show in the outlook sent folder... I hope you know what I mean.. Thanks in advance.
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 40348545
mail.dll will not do that. It has to be configured with the credentials of the user to connect to the Exchange server. Also, it won't put emails in the sent items.

You are probably better to stick with automation then!
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 40348547
0
 

Author Comment

by:fmichail
ID: 40352790
Hi Eric,
Yes I tried the same code, but unfortunately, I got the same error in the same spot. by the way, is it the same to reference MS outlook object library (as in your like) OR to reference MS.Office.Interop.outlook?.
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 40352922
yes
0
 

Author Closing Comment

by:fmichail
ID: 40353410
Although my problem is not fixed, however, Eric directed to a better way of handling Emails, that I will definitely consider. Thanks Eric
0

Featured Post

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…

632 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question