Solved

Macro to read email.

Posted on 2001-07-17
2
220 Views
Last Modified: 2012-08-13
Hi,

I need to be able read the content of every message in a folder - the folder will always be the same so it can be hard coded.

(I intended to dump this info to a text file - I can do this bit!)

Cheers

Rupert
0
Comment
Question by:ruperts
[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
2 Comments
 
LVL 2

Accepted Solution

by:
Paullkha earned 100 total points
ID: 6298979
Option Compare Database
Option Explicit

Private olapp As Outlook.Application
Private olns As Outlook.NameSpace

'****************************************
'With this code, folder can be "anywhere"
'****************************************
Private Function MessageFldrExists() As Outlook.MAPIFolder
On Error GoTo err_DNE
    Dim olFolders As Outlook.MAPIFolder
   
    Set olFolders = olns.Folders("Personal Folders")
    Set MessageFldrExists = olFolders.Folders("MessageMail")
   
    Exit Function
   
err_DNE:
    Set MessageFldrExists = Nothing
End Function
Private Sub olLogon()
    Set olapp = New Outlook.Application
    Set olns = olapp.GetNamespace("MAPI")
    olns.Logon
   'dont proceed until logged on
   DoEvents
End Sub

Private Sub olLogoff()
    DoEvents
   'dont quit until all finished
    olns.Logoff
    Set olns = Nothing
    Set olapp = Nothing
End Sub

Private Sub MessageFldr2Table()
Dim Messagefldr As Outlook.MAPIFolder
Dim itmMail As Outlook.MailItem
Dim itmsMail As Outlook.Items
Dim strBody As String
   
    Call olLogon
    Set Messagefldr = MessageFldrExists()
    If Not (Messagefldr Is Nothing) Then
        Set itmsMail = Messagefldr.Items
        For Each itmMail In itmsMail
'****************
'Here is the place to put in sending strBody to a file
'****************
            strBody = itmMail.Body
        Next
    End If
    Call olLogoff
End Sub
=========
Note:
You must have a reference to Outlook object set somewhere.



0
 

Expert Comment

by:PandoraMod
ID: 6366486
ruperts, are you still having a problem? If so, please provide more information. If you solved your problem, please let us know how and then we can archive this.

Thanks,
PandoraMod
Moderator @ Experts Exchange
e-mail: pandoramod@experts-exchange.com
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
MS Outlook is a world-class email client application that is mainly used for e-communication globally.  In this article, we will discuss the basic idea about MS Outlook, its advanced features, and types of MS Outlook File formats.
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

749 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