Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB with data from outlook 1

Status
Not open for further replies.

D2C

Programmer
Aug 27, 2001
86
BE
Hello everybody,

They assigned a new taks to me, I should make a form that calculates how much mails where sent to a certain person. This form should be stored locally, as the email client is also. I am ussing VB express edition 2005.
Can somebody point me to some usefull links, or maybe give me some hints to get started?

tnx a lot!
greetz,
d2c
 
here is some code that should help you.

Code:
 Dim objOutlook As Outlook._Application = New Outlook.Application
 Dim objNS As Outlook._NameSpace = objOutlook.Session
 Dim objLocalItems As Outlook.Items
 Dim objfolder2 As Outlook.MAPIFolder
 dim o as Outlook.MailItem
 objfolder2 = objNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox)
 objLocalItems = objfolder2.Items

 for each o in objlocalitems
   'do what you need to do
 next

Christiaan Baes
Belgium

If you want to get an answer read this FAQ faq796-2540
There's no such thing as a winnable war - Sting
 
As objLocalItems is not a collection, you'll most likely need this construct:
Code:
        For i = 1 To objLocalItems.Count
            objVar = objLocalItems.Item(i)
        Next
 
sorry.

Christiaan Baes
Belgium

If you want to get an answer read this FAQ faq796-2540
There's no such thing as a winnable war - Sting
 
No problem, Christiaan. Thanks to your code, I was able to get that far.
 
dimandja you really mean I helped you.

What do you do these days without history?

Christiaan Baes
Belgium

If you want to get an answer read this FAQ faq796-2540
There's no such thing as a winnable war - Sting
 
Thanks for all your help!

En Christiaan, bedankt voor jouw start!
Ben ook van België!

Groeten,
d2c
 
link: FAQ 4
Nice Outlook Only link:
If you are going to read a large number of messages from an Outlook folder, try to limit the number of the messages first. For example if you are looking for the messages from John Smith, do not loop through all the messages, let Outlook do the dirty work:
Code:
Set Items = MAPIFolder.Items
Set Msg = Items.Find("[SenderName] = 'John Smith'")
Do While not (Msg is Nothing)
  ' now you can access the message
  Debug.Print Msg.Subject
  Set Msg = Items.FindNext
Loop



Have a great day!

j2consulting@yahoo.com
 
>dimandja you really mean I helped you.

Yes you did. I copied and pasted it in VS, and proceeded to experiment with it.


>What do you do these days without history?

I get to actually do important things. [wink]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top