Appointment Form and Task Form

  • Thread starter Thread starter Simonglencross
  • Start date Start date
S

Simonglencross

I have looked through the entire news group but can not find an answer to my
question which is----

Is it possible to import the appointment form and task form from outlook so
it can be used within access therefore I would have to start designing forms
from scratch which are already there? Any info or advice would be much
appreciated!!

Thank you!
 
Yes. Following is an example taken from an app I've written.

Private Function funcScheduleContact()
On Error GoTo Err_funcScheduleContact

' save this record to ensure changes are written to disk
RunCommand acCmdSaveRecord

' create the Outlook calendar item per specs
Dim objOutlook As New Outlook.Application
Dim objNameSpace As Outlook.NameSpace
Dim objMAPIFolder As Outlook.MAPIFolder
Dim objMAPIFolderContact As Outlook.MAPIFolder
Dim objAppt As Outlook.AppointmentItem
Dim objContact As Outlook.ContactItem
Dim objItems As Outlook.Items
Dim objLink As Outlook.Link
Dim strEntryID As String

Dim rs As Recordset

Set objNameSpace = objOutlook.GetNamespace("MAPI")
Set objMAPIFolder = objNameSpace.Folders("Personal
Folders").Folders("Calendar")
Set objMAPIFolderContact = objNameSpace.Folders("Public
Folders").Folders("All Public Folders").Folders("iCap Contacts")

' create an appointment object against this folder
Set objAppt = objMAPIFolder.Items.Add(objMAPIFolder.DefaultItemType)

' add a link (this contact, that is)
Set objContact = objNameSpace.GetItemFromID(OutlookEntryID,
objMAPIFolderContact.StoreID)
If Not objContact Is Nothing Then objAppt.Links.Add objContact: Set
objContact = Nothing

' display the scheduled item
objAppt.Display True

' return the EntryID and store for OLE updating purposes
strEntryID = objAppt.EntryID

' if an entry exists, then this item was created
' add this information to the schedule table to ensure quick
association of the item
If strEntryID <> "" Then

' open the schedule rs and add this item
Set rs = CurrentDb.OpenRecordset("tblSchedule")
rs.AddNew
rs!ContactID = ContactID
rs!OutlookTypeID = 1 ' Appointment is 1
rs!StartTime = objAppt.Start
rs!EndTime = objAppt.End
rs!UserID = DLookup("[UserID]", "qryCurrentUser")
If objAppt.Subject <> "" Then rs!Subject = objAppt.Subject
rs!OutlookEntryID = strEntryID
rs.Update
Set rs = Nothing

' requery the schedule form if open
If ogViewOption = 3 Then fsubConSchedule.Form.Requery
End If
Set objAppt = Nothing

Exit_funcScheduleContact:
Set rs = Nothing
Set objContact = Nothing
Set objAppt = Nothing
Set objMAPIFolder = Nothing
Set objNameSpace = Nothing
Set objOutlook = Nothing
Exit Function

Err_funcScheduleContact:
ErrorHandler "Form: frmConBase", "funcScheduleContact", Err.Number,
Err.Description
Resume Exit_funcScheduleContact

End Function
 
Is there any further information you can give me on this Greysky I'm new to
programming and could do with a little more advice!

Many thanks in advance.

Simon
GreySky said:
Yes. Following is an example taken from an app I've written.

Private Function funcScheduleContact()
On Error GoTo Err_funcScheduleContact

' save this record to ensure changes are written to disk
RunCommand acCmdSaveRecord

' create the Outlook calendar item per specs
Dim objOutlook As New Outlook.Application
Dim objNameSpace As Outlook.NameSpace
Dim objMAPIFolder As Outlook.MAPIFolder
Dim objMAPIFolderContact As Outlook.MAPIFolder
Dim objAppt As Outlook.AppointmentItem
Dim objContact As Outlook.ContactItem
Dim objItems As Outlook.Items
Dim objLink As Outlook.Link
Dim strEntryID As String

Dim rs As Recordset

Set objNameSpace = objOutlook.GetNamespace("MAPI")
Set objMAPIFolder = objNameSpace.Folders("Personal
Folders").Folders("Calendar")
Set objMAPIFolderContact = objNameSpace.Folders("Public
Folders").Folders("All Public Folders").Folders("iCap Contacts")

' create an appointment object against this folder
Set objAppt = objMAPIFolder.Items.Add(objMAPIFolder.DefaultItemType)

' add a link (this contact, that is)
Set objContact = objNameSpace.GetItemFromID(OutlookEntryID,
objMAPIFolderContact.StoreID)
If Not objContact Is Nothing Then objAppt.Links.Add objContact: Set
objContact = Nothing

' display the scheduled item
objAppt.Display True

' return the EntryID and store for OLE updating purposes
strEntryID = objAppt.EntryID

' if an entry exists, then this item was created
' add this information to the schedule table to ensure quick
association of the item
If strEntryID <> "" Then

' open the schedule rs and add this item
Set rs = CurrentDb.OpenRecordset("tblSchedule")
rs.AddNew
rs!ContactID = ContactID
rs!OutlookTypeID = 1 ' Appointment is 1
rs!StartTime = objAppt.Start
rs!EndTime = objAppt.End
rs!UserID = DLookup("[UserID]", "qryCurrentUser")
If objAppt.Subject <> "" Then rs!Subject = objAppt.Subject
rs!OutlookEntryID = strEntryID
rs.Update
Set rs = Nothing

' requery the schedule form if open
If ogViewOption = 3 Then fsubConSchedule.Form.Requery
End If
Set objAppt = Nothing

Exit_funcScheduleContact:
Set rs = Nothing
Set objContact = Nothing
Set objAppt = Nothing
Set objMAPIFolder = Nothing
Set objNameSpace = Nothing
Set objOutlook = Nothing
Exit Function

Err_funcScheduleContact:
ErrorHandler "Form: frmConBase", "funcScheduleContact", Err.Number,
Err.Description
Resume Exit_funcScheduleContact

End Function


Simonglencross said:
I have looked through the entire news group but can not find an answer to my
question which is----

Is it possible to import the appointment form and task form from outlook so
it can be used within access therefore I would have to start designing forms
from scratch which are already there? Any info or advice would be much
appreciated!!

Thank you!
 
Back
Top