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!

Outlook Question

Status
Not open for further replies.

gnikol1

IS-IT--Management
Jan 30, 2002
29
EU
Hi,
Is there any unique identifier of each mail entered in the outlook?
I want to keep in a database this reference together with comments.

Is it possible?

Thanks in advance
 
Construct your db table with an autonumber field and use that as the ID

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'
 
I think you can also use the EntryID to uniquely identify a message. i.e.
Code:
Dim objOutlook As New Outlook.Application
Dim objNameSpace As Outlook.NameSpace
Dim objInbox As MAPIFolder
Dim objMail As MailItem

Set objNameSpace = objOutlook.GetNamespace("MAPI")
Set objInbox = objNameSpace.GetDefaultFolder(olFolderInbox)

' Find each ID
For Each objMail In objInbox.Items
   MsgBox objMail.EntryID & " - " & objMail.Subject
Next objMail
{/code]

I can't test this at the moment so I apologise if there is anything I've overlooked but give it a try and let me know...

----------------------------------------------------------------------

Need help finding an answer?

Try the search facilty ([URL unfurl="true"]http://www.tek-tips.com/search.cfm)[/URL] or read FAQ222-2244 on how to get better results.
 
Each item in a MAPI folder has a unique EntryID that only changes when the item is moved to different folder. The length of the ID depends on whether the messages are stored in a pst file or on Exchange Server; if you allow 240 chars field length it should be OK:

Set objOLApp = CreateObject("Outlook.Application")
Set objNS = objOLApp.GetNameSpace("MAPI")
Set objFolder = objNS.GetDefaultFolder(olFolderInbox)
'Get the StoreID of the Inbox
Debug.Print "StoreID: " & objFolder.StoreID
'List the EntryID of items in the Inbox
For Each objItem In objFolder.Items
Debug.Print "EntryID: " & objItem.EntryID
Next

If you store the EntryID in the database and update it if the item is moved then you can use the ID to retrieve the item from Outlook using the GetItemFromID method of the Namespace object.

Paul Bent
Northwind IT Systems
 
The previous helped a lot thanks.

Is it possible to open a mail with the specific entry ID?

Thanks again....

 
Yes I guess so...probably a bit like:
Code:
For Each objMail In objInbox.Items
    If objMail.EntryID = intID Then objMail.Display
Next objMail
obviously where intID is the ID you wish to open.

----------------------------------------------------------------------

Need help finding an answer?

Try the search facilty ( or read FAQ222-2244 on how to get better results.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top