473,394 Members | 1,481 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Retrieve Information from Outlook

maxamis4
295 Expert 100+
Hello,

I am currious to know how I can extract information from outlook into access. So far I have this code which I am using to test, but I can' t find any other information on the net. All I want to extract is the
To
and
From
fields from outlook. Below is my code

Expand|Select|Wrap|Line Numbers
  1. Public Sub Message()
  2.     Dim rst As DAO.Recordset
  3.    '## Declare Outlook objects.
  4.     Dim ol As New Outlook.Application
  5.     Dim olns As Outlook.NameSpace
  6.     Dim cf As Outlook.MAPIFolder ' Items in Inbox
  7.     Dim objItems As Outlook.Items
  8.     Dim Prop As Outlook.UserProperty
  9.    '## End Declare Outlook
  10.  
  11.  Dim objOutlookMsg As Object
  12.  Dim Item As Object
  13.  Dim Atmt As Attachment
  14.  Dim FileName As String
  15.  Dim i As Integer
  16.  
  17. Set olns = GetNamespace("MAPI")
  18.  
  19. Set cf = olns.GetDefaultFolder(olFolderInbox)
  20.  Debug.Print cf
  21.  
  22.  i = 0
  23.  If cf.Items.Count = 0 Then
  24.     MsgBox "there are no messages in that box"
  25.     Exit Sub
  26.  End If
  27.     For Each Item In cf.Items
  28.  
  29.    Debug.Print Item.Subject ' here is where I want to retrieve the fields
  30.     '.Subject
  31.     '.body
  32.     Next Item
  33. End Sub
  34.  
  35.  
Thanks for any help
Jan 2 '07 #1
7 3056
Kosmos
153 100+
I don't get what the question is...is the for each not working properly with outlook? If not you could try a loop and a with until IsEmpty(Items) or something like that? I'm not completely familiar with how outlook works with access...but I'm currently trying to do something with it myself and somewhat miserably failing so take my advice for what it's worth lol.

also maybe there's some sort of read command you need to do first? I'll let you know if I come across anything more useful.
Jan 2 '07 #2
maxamis4
295 Expert 100+
Now the code works fine, my problem is that I don't know all the outlook constants. like body = message, subject = subject. I want to know how to mine/retrieve the to and from field from outlook.

What exactly are you working on, maybe I can help you with that?

Thanks for the reply
Jan 2 '07 #3
Kosmos
153 100+
oh great...yeah I thought I had seen that get command so I wasn't sure why it wasn't working properly. I'm trying to add multiple attachments to access...but they aren't simple file locations....the code is here:
http://www.thescripts.com/forum/show...47#post2286847

I'm not even sure it's something I can do. I've been searching all day and I haven't even seen a website that's touched on this subject...including an online university type of thing this company has....but any help would be very appreciated...thanks :)
Jan 2 '07 #4
NeoPa
32,556 Expert Mod 16PB
If the Item referred to is an Outlook.MailItem item, then To is a string property but From doesn't exist. SenderName is also a string which might return what you're after.
Jan 3 '07 #5
NeoPa
32,556 Expert Mod 16PB
To find out these details go to the VBA window in Outlook and press F2 (Object Browser).
In the DropDown which says All Libraries, select Outlook.
Find MAPIFolder in the classes list, then see Items as a Member (property).
From here I guessed that this was a collection property containing Mails and/or Contacts and/or Notes etc.
I found a class MailItem so looked in the Members list for To - found and From - not found.
I looked around further and found SenderName.
There are other members and methods of this class listed.
Jan 3 '07 #6
maxamis4
295 Expert 100+
Excellent suggestion. Wow I have more than a handful thank you so much
Jan 3 '07 #7
NeoPa
32,556 Expert Mod 16PB
No problem.
Glad to help.
Jan 3 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Maya | last post by:
Hello Everybody, I have an application that receives a text in this format: Received from john by server.com with ESMTP (SMTPD32-8.05) id AD5258A0142; Sun, 01 Aug 2004 02:54:26 +0100 From:...
3
by: Richard Thornley | last post by:
Hello, I was just been given a project and I have some questions on how to accomplish the first part of the task. If a user sends an email to a specific email address I need to detect...
2
by: Mamatha | last post by:
Hi I have a doubt,how to know the information of .pst file? I want to display the information of pst file (which is maintained by the outlook express) in VB.NET form.When i click a button in...
4
by: Mamatha | last post by:
Hi I need to know..how to retrieve values of Microsoft Outlook in VB,i want to retrieve how many emails contains in my inbox,outbox,sentitems etc. Please give me the solution for retrieving...
9
by: Don | last post by:
Say I have a class like so: Public Class MyClass Public Prop1 as Integer Public Prop2 As Integer Public Prop3 As Integer End Class Is it possible to retrieve a list of the variables or...
2
by: Noro | last post by:
Hi All, When I try to get the email address of the current user, I retrieve a string like this that represents the email address: /o=ORGANIZATION/ou=Sede/cn=Recipients/cn=USERNAME What can...
2
by: Torpedoke | last post by:
Hello, I was wondering if it was possible to retrieve the emailsettings of Outlook or Outlook Express with vb.net? If yes does somebody perhaps has a sample code? If not how can I send a email...
0
by: silentcacophony | last post by:
hello i need some help.. I am creating an application where a button is added in the outlook tool bar . Now when i select this button . it should open a windows form showing the selected the...
0
by: gidiop | last post by:
I need to retrieve the outlook's profiles (using C#). I thought that this could be done via the Outlook object model, but I can't find the way doing it. Any help will be appreciated, Oren.
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.