populating worksheet with Outlook mail

  • Thread starter Thread starter VG9uZXk
  • Start date Start date
Status
Not open for further replies.
V

VG9uZXk

Hello. I want to populate a worksheet with my Outlook inbox content (all 2007

versions with Vista). I get erros on invalid params on olFolderInbox as

indicated in code below. (I sometimes get erros on creating the initial app

object, but not as often). BTW, I run this code from Excel, and I have

created ref to outlook library.

Sub getMail()

Dim ol As Outlook.Application

Dim ns As Namespace

Dim folder As MAPIFolder

Dim ws As Worksheet

Dim i As Integer

Set ol = CreateObject("Outlook.Application")

Set ns = ol.GetNamespace("MAPI")

ns.Logon

'errors about parameter value not valid on next line:

Set folder = ns.GetDefaultFolder(olFolderIndox)

Set ws = Worksheets("Receive Mail")

For i = 1 To folder.Items.Count

With folder.Items(i)

ws.[A1].Offset(i, 0) = .SenderName

ws.[A1].Offset(i, 1) = .SenderEmailAddress

ws.[A1].Offset(i, 2) = .Subject

ws.[A1].Offset(i, 3) = .Size

ws.[A1].Offset(i, 4) = .ReceivedTime

ws.[A1].Offset(i, 5) = .Left(.Body, 100)

End With

Next i

ns.Logoff

Set ol = Nothing

End Sub
 
Look at that problem statement again to find the typo. It doesn't say

olFolderInbox at all.

Sue Mosher

"Toney" <Toney> wrote in message

news:BFEF6362-373E-46B1-9FAD-C25913FDDDA1@microsoft.com...
> Hello. I want to populate a worksheet with my Outlook inbox content (all
> 2007
> versions with Vista). I get erros on invalid params on olFolderInbox as
> indicated in code below. (I sometimes get erros on creating the initial
> app
> object, but not as often). BTW, I run this code from Excel, and I have
> created ref to outlook library.

> Sub getMail()

> Dim ol As Outlook.Application
> Dim ns As Namespace
> Dim folder As MAPIFolder
> Dim ws As Worksheet

> Dim i As Integer

> Set ol = CreateObject("Outlook.Application")
> Set ns = ol.GetNamespace("MAPI")
> ns.Logon

> 'errors about parameter value not valid on next line:

> Set folder = ns.GetDefaultFolder(olFolderIndox)

> Set ws = Worksheets("Receive Mail")

> For i = 1 To folder.Items.Count
> With folder.Items(i)

> ws.[A1].Offset(i, 0) = .SenderName
> ws.[A1].Offset(i, 1) = .SenderEmailAddress
> ws.[A1].Offset(i, 2) = .Subject
> ws.[A1].Offset(i, 3) = .Size
> ws.[A1].Offset(i, 4) = .ReceivedTime
> ws.[A1].Offset(i, 5) = .Left(.Body, 100)

> End With
> Next i

> ns.Logoff
> Set ol = Nothing

> End Sub

>
 
Dang. This is why I should type everyting in lower cases, to help me find

these errors. This time, I probably didn't do this.

Thanks much. My code words now.

Toney

"Sue Mosher [MVP]" wrote:


> Look at that problem statement again to find the typo. It doesn't say
> olFolderInbox at all.

> > Sue Mosher
> > >

> "Toney" <Toney> wrote in message
> news:BFEF6362-373E-46B1-9FAD-C25913FDDDA1@microsoft.com...
> > Hello. I want to populate a worksheet with my Outlook inbox content (all
> > 2007
> > versions with Vista). I get erros on invalid params on olFolderInbox as
> > indicated in code below. (I sometimes get erros on creating the initial
> > app
> > object, but not as often). BTW, I run this code from Excel, and I have
> > created ref to outlook library.
> > Sub getMail()
> > Dim ol As Outlook.Application
> > Dim ns As Namespace
> > Dim folder As MAPIFolder
> > Dim ws As Worksheet
> > Dim i As Integer
> > Set ol = CreateObject("Outlook.Application")
> > Set ns = ol.GetNamespace("MAPI")
> > ns.Logon
> > 'errors about parameter value not valid on next line:
> > Set folder = ns.GetDefaultFolder(olFolderIndox)
> > Set ws = Worksheets("Receive Mail")
> > For i = 1 To folder.Items.Count
> > With folder.Items(i)
> > ws.[A1].Offset(i, 0) = .SenderName
> > ws.[A1].Offset(i, 1) = .SenderEmailAddress
> > ws.[A1].Offset(i, 2) = .Subject
> > ws.[A1].Offset(i, 3) = .Size
> > ws.[A1].Offset(i, 4) = .ReceivedTime
> > ws.[A1].Offset(i, 5) = .Left(.Body, 100)
> > End With
> > Next i
> > ns.Logoff
> > Set ol = Nothing
> > End Sub
> >


>
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
A Outlook Reminders not populating for certain events Using Outlook 2
D populating listbox on custom form from Access Outlook VBA and Custom Forms 7
T populating multiple calendars without invites Using Outlook 1
microsvc Populating everyone's calendar with campus events Exchange Server Administration 1
T Populating listbox with MS Access table Using Outlook 2
S Custom field not populating in Custom View or Mail Merge Exchange Server Administration 2
B Populating Additional Outlook Column with Date \ Time Using Outlook 0
R My email merge/business contact manager fields are not populating BCM (Business Contact Manager) 1
T populating fields with information from the address book Outlook VBA and Custom Forms 5
M BCM History 'From' field not populating BCM (Business Contact Manager) 2
O Worksheet doesn't show on jumplist Using Outlook 1
L Open an Exel Macro Enabled Worksheet Using Outlook 4
ughlook Open multiple contacts in NEW Outlook? Using Outlook 2
G Outlook translation feature is off Using Outlook 2
J Outlook 2010 does not let me put any account Using Outlook.com accounts in Outlook 3
P 3 of 5 PST files don't install from d:\outlook but only from D:\ Using Outlook 7
HarvMan January Windows 10 preview update force installs new Outlook Using Outlook 1
L Outlook 2010 - new installation on Windows 11 - aplzod32.dll is not a valid Add-in Using Outlook 12
J Outlook troubleshooting/logging - option grayed out Using Outlook 2
B Arrows missing from Outlook emails vertical scrollbar Using Outlook 0
G Outlook 2021 (New) doesn't respect default browser Using Outlook 8
B Outlook or iPhone turning tabs into spaces in Outlook Notes Using Outlook 1
P newly installed Office 365 includes OLD Outlook Using Outlook 6
R Outlook ribbon menu default? Using Outlook 7
H Spam email in Gmail not visible in Outlook Using Outlook 3
J How to transfer Win 10 Outlook to new Windows 11 pc? Using Outlook 11
J Renegade spam URL line displayed in old local Outlook 365 email title Using Outlook 3
G Reduce whitespace in Outlook desktop Contact Cards display Using Outlook 3
C Outlook classic via 365 Using Outlook 2
Dr. Demento Analogous Outlook code to read info into an array (or collection or whatever) Outlook VBA and Custom Forms 7
S Repair Outlook Using Outlook 8
V Outlook Form ListBox is not editable Outlook VBA and Custom Forms 2
F Outlook's contacts Using Outlook 1
D Outlook 2003 stopped dead Using Outlook 2
G Cannot receive emails from gmail account in Outlook 365 Using Outlook 1
E "Cannot display the folder. MS Outlook cannot access the specified file location" Using Outlook 8
P Outlook 2016 Working Offline Using Outlook 2
Rupert Dragwater Cannot reestablish gmail (email address) account in Outlook 365 Using Outlook 11
O Outlook 365 synchronisieren Exchange Server Administration 1
kburrows Outlook Classic - JPG files are corrupted when opened or saved Using Outlook 3
F Sync Outlook Calendar Using Outlook 0
G Change default font size in sticky notes - Outlook Desktop 2021 Using Outlook 2
C VBA in "New Outlook?" Using Outlook 0
D New Outlook with Business Basic Plans Using Outlook 0
D Outlook 2021 not working with Outlook 2003 installed Using Outlook 5
D Outlook 2003 stopped working - get they dialog box asking for username & Password Using Outlook 2
T Outlook 2021 hangs in close on taskbar occasionally Using Outlook 1
M Duplicate removal feature in Outlook 2021 is faulty Using Outlook 2
D.Moore Outlook COM addins source folder Using Outlook 12
P Removing Outlook 365 Account from Send/Receive Using Outlook 3

Similar threads

Back
Top