A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

populating worksheet with Outlook mail



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old April 11th 09, 04:28 AM posted to microsoft.public.outlook.program_vba
Toney
external usenet poster
 
Posts: 2
Default populating worksheet with Outlook mail

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, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"Toney" wrote in message
...
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





 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Trying to import from an Excel worksheet Jan Outlook - Using Contacts 6 November 9th 07 01:37 AM
Outlook contacts list into Excel worksheet? Ed Outlook and VBA 3 February 1st 07 11:33 PM
i can't get outlook to import info from the worksheet it created oaksie1 Outlook - General Queries 5 July 20th 06 05:13 PM
Help emailing worksheet range via Redemption [email protected] Outlook and VBA 1 July 17th 06 06:36 PM
Hyperlinking from Outlook 2003 to an excel Worksheet fidgitthedigit Outlook - General Queries 2 May 5th 06 04:32 PM


All times are GMT +1. The time now is 02:54 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.