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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Outlook Entry ID question 1

Status
Not open for further replies.

vanvb

Programmer
Feb 7, 2003
255
CA
I am writing an app that creates an Outlook appointment, shows it for the user to fill in optional parts, then I want to store the entry ID and then be able to retrieve and display that appointment later. I have one question.

I have this code below that creates and displays the appointment. I know that I need to store the Entry ID, but it seems that everywhere I put the code to store the Entry ID, it is blank at that point. Where in the code below do I need to put the entry ID code? Or is the Entry ID only created when I save the appointment?

Code:
Public Function OutlookAppointment(sAttendees As String, sSubject As String, sLocation As String, strType As String) As String
    Dim oAppointment As Outlook.AppointmentItem
    Dim oOutlook As Outlook.Application
    Dim oFolder As MAPIFolder
    Dim oItems As Items

    ' Start Outlook
    Dim olApp As Outlook.Application
    Set olApp = CreateObject("Outlook.Application")
     
    ' Logon
    Dim olNs As Outlook.NameSpace
    Set olNs = olApp.GetNamespace("MAPI")
    olNs.Logon

    Set oOutlook = New Outlook.Application
    Set oAppointment = Outlook.CreateItem(olAppointmentItem)
    
    'Set meeting parameters
    With oAppointment
    
        .Duration = 30       '(in minutes)
        .Location = sLocation
        If strType = "Meeting" Then
            .MeetingStatus = olMeeting
        End If
        .Subject = sSubject
        .BusyStatus = olBusy
        .ReminderSet = True
        .ReminderMinutesBeforeStart = 30   '(in Minutes)
     
        
    End With
    
    
    If strType = "Meeting" Then
        'Add attendees
        With oAppointment.Recipients.Add(sAttendees)
            .Type = 1   '1 = Required, 2 = Optional
        End With
    End If

    oAppointment.Display
    
    Set olApp = Nothing
    Set olNs = Nothing
    Set oAppointment = Nothing
    Set oOutlook = Nothing

End Function

Thanks...any help would be appreciated.
Note that the above is not my code. It came from a previous post here and I adapted it as I required.
 
' Start Outlook
Dim olApp As Outlook.Application
Set olApp = New Outlook.Application
' Logon
Dim olNs As Outlook.NameSpace
Set olNs = olApp.GetNamespace("MAPI")
olNs.Logon
Set oOutlook = New Outlook.Application
Set oAppointment = olApp.CreateItem(olAppointmentItem)

That should help.

Andy
"Logic is invincible because in order to combat logic it is necessary to use logic." -- Pierre Boutroux
 
Andy,
I changed the line as you suggested and put in the line:
MsgBox "{" & oAppointment.EntryID & "}"

(the brackets are just to deliminate the result)
I put that line in just before and after oAppointment.Display. It shows the appointment appropriately, but the EntryID is still blank.
Any ideas?
 
From Outlook VBA Help File:

EntryID Property
Returns the unique entry ID of the object. This property corresponds to the MAPI property PR_ENTRYID. MAPI systems assign a permanent, unique ID string when an object is created that does not change from one MAPI session to another. The EntryID property is not set for an Outlook item until it is saved or sent. Also, the EntryID changes when an item is moved into another folder.

(My italics) You have saved/sent it, haven't you?

Andy
"Logic is invincible because in order to combat logic it is necessary to use logic." -- Pierre Boutroux
 
That's my problem right there. I had actually found that just after my last post. What I want to be able to do is just display the appointment but not save it. I want the user to save it after making the changes necessary...like setting the date. I guess I'll have to just save it, then open it again, then display that and allow the user to make the necessary changes then.

Thanks for your help.
 
If the EntryID is as big as I think it will be (assuming equivalence with the MessageID in a MailItem) then it is going to be utterly meaningless to the user. It is long.

Glad I could be of help, and thanks for the star.

Andy
"Logic is invincible because in order to combat logic it is necessary to use logic." -- Pierre Boutroux
 
It's not for the user. EntryID is big...but what I am doing is associating an appointment with a problem request in our helpdesk system. This allows us to create an appointment, then look at it later because the system will keep the appointment's entryid is the database associated with the problems. Thanks for the help.
 
Ah, I see. I had visions of users jotting down the easy-to-remember EntryID on Post-Its! [lol]

Andy
"Logic is invincible because in order to combat logic it is necessary to use logic." -- Pierre Boutroux
 
I usually write both the StoreID and EntryID to the database so I can use the GetItemFromID method of the Namespace object.

Allow at least 150 chars for the EntryID string and if you use StoreID you may need a "memo" type field. The length varies depending whether the info store is on Exchange Server or a in pst file. I got caught out once developing in c/w mode and distributing the app to a client running in internet-only mode. His StoreID's were over 100 chars longer for the same items!

Paul Bent
Northwind IT Systems
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top