dbTalk Databases Forums  

Paradox, OLE, Outlook and Modify etc

comp.databases.paradox comp.databases.paradox


Discuss Paradox, OLE, Outlook and Modify etc in the comp.databases.paradox forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
OzPaul
 
Posts: n/a

Default Paradox, OLE, Outlook and Modify etc - 06-06-2006 , 09:27 PM






I have searched long and hard for an example of Opal code to modify an
existing MS Outlook Appointment using OLE. What puzzles me is that
plenty of people have asked the same question (albeit not that often
with Paradox) over the years and there are very few detailed examples
of how to find an appointment and modify it or delete it. This
contrasts with the trumpeted details showing how easy it is to create a
new appointment in Outlook using OLE! Generally, people who ask about
modifying and deleting are met with a deafening silence. It is enough
to make me think there is a conspiracy against knowing this
information. Yet it is fairly cruical to applying this functionality in
a real world application. I have seen code showing how to do this in
other languages but I am realy only familiar with Opal (I'm not a
professional programmer) so I would need to give more time than is
warranted to sort out the equivalent Opal code. I have been trying to
check thedbcommunity for a couple of days but the web site seems to be
down. So if any body is willing to share their code with me I would be
eternally gratetful. Regards Paul


Reply With Quote
  #2  
Old   
Liz McGuire
 
Posts: n/a

Default Re: Paradox, OLE, Outlook and Modify etc - 06-06-2006 , 09:33 PM






Paul,

I'd recommend posting the other code, or links thereto, in its
simplest form - there are at least a few here who should be able to
translate it into ObjectPAL (assuming that's possible).

Another option might be to delete the original appointment and send a
new one with the changes made.... If it comes to it.

Liz


OzPaul wrote:
Quote:
I have searched long and hard for an example of Opal code to modify an
existing MS Outlook Appointment using OLE. What puzzles me is that
plenty of people have asked the same question (albeit not that often
with Paradox) over the years and there are very few detailed examples
of how to find an appointment and modify it or delete it. This
contrasts with the trumpeted details showing how easy it is to create a
new appointment in Outlook using OLE! Generally, people who ask about
modifying and deleting are met with a deafening silence. It is enough
to make me think there is a conspiracy against knowing this
information. Yet it is fairly cruical to applying this functionality in
a real world application. I have seen code showing how to do this in
other languages but I am realy only familiar with Opal (I'm not a
professional programmer) so I would need to give more time than is
warranted to sort out the equivalent Opal code. I have been trying to
check thedbcommunity for a couple of days but the web site seems to be
down. So if any body is willing to share their code with me I would be
eternally gratetful. Regards Paul

Reply With Quote
  #3  
Old   
OzPaul
 
Posts: n/a

Default Re: Paradox, OLE, Outlook and Modify etc - 06-06-2006 , 10:02 PM



Liz. So fast! Hmm, Well here is some code I book-marked from an Outlook
group. From what I can see, he is storing an ID value in Access to use
it with Delete. I have tried simply populating an OLE variable with the
details I used to create an appointment then ^delete and I get no error
message but also no delete! Probably too simple minded. Paul.


Thanks Sue - Here is cut down code as requested [ it does the add's OK
but
not the delete's - fails on Set objAppointment =
objOutlook.Session.GetItemFromID(CalEntryID) ] :-

Dim objOutlook As Outlook.Application
Dim objCalendar As Object
Dim objAppointment As Object
Dim CalEntryID as Variant
Dim CalEntryIDR as Object
Dim SQLcmd as String


Set objOutlook = New Outlook.Application
Set objCalendar =
objOutlook.Session.GetDefaultFolder(olFolderCalend ar)


Select Case Action


Case "A"


cc = 0


Do While cc <= 2


Set objAppointment = objCalendar.Items.Add
With objAppointment
.Subject = "Test"
.Start = Date + cc
.AllDayEvent = True
End With


objAppointment.Close olSave


CalEntryID = objAppointment.EntryID


SQLcmd = "Insert into table tblx (EN,EI) values ('" & cc & "', '" &
CalEntryID & "')"
Docmd.RunSQL SQLcmd


cc = cc + 1


Loop


Case "D"


cc = 0


Do While cc <= 2


CalEntryID = DLookup("[EI]", "tblx", "[EN] = " & cc)
Set objAppointment = objOutlook.Session.GetItemFromID(CalEntryID)
objAppointment.Delete


cc = cc + 1


Loop


End Select


Set objAppointment = Nothing
Set objOutlook = Nothing


---------



- Hide quoted text -
- Show quoted text -

"Sue Mosher [MVP-Outlook]" wrote:
Quote:
Show the code used to instantiate the Namespace and to save the items and
get their EntryIDs.

GetItemFromID returns an object. You need to use Set:

Quote:
Set CalEntryIDR = objNS.GetItemFromID(CalEntryID)

Quote:
--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

Quote:
"Andy" <A... (AT) discussions (DOT) microsoft.com> wrote in message
news:F52F1C45-D96D-416F-8B3F-77EA651E7B0F (AT) microsoft (DOT) com...
Sue - Sorry to push a bit more on this subject but it is interesting.
Firstly, I took your advice and looked at the VBA help files to work out
the
syntax of the various methods. I did struggle with Namespace though and
found
that I had to use Session instead.

Quote:
Anyway - I created 3 Appointment items one after the other and saved each
before obtaining their EntryID - suprisingly each EntryID was the same
even
though the 3 appointments were on different days albeit with the same
Subject
for each.

Quote:
I stored these away but when I came to later use them to delete the
appointments, I got a failure when I tried to set a variable as follows :-

Quote:
CalEntryIDR = objOutlook.Session.GetItemFromID(CalEntryID) ' CalEntryID is
the long EntryID value

Quote:
Also when I actually got this statement to work (just after creating the
appointment) the returned value was the Subject of the appointment ???

Quote:
Any ideas? Especially the difference between Namespace and Session and why
the 3 IDs were the same above.

Quote:
Thanks.

Quote:
The variable CalEntryID contains the long EntryID value.
"Sue Mosher [MVP-Outlook]" wrote:

Quote:
When in doubt, check the object browser: Press ALt+F11 to open the VBA
environment in Outlook, then press F2. Switch from <All Libraries> to
Outlook to browse all Outlook objects and their properties, methods, and
events. Select any object or member, then press F1 to see its Help topic.

Quote:
"Andy" <A... (AT) discussions (DOT) microsoft.com> wrote in message
news:56FDB3C3-9810-4877-A442-D7F393FC8AE7 (AT) microsoft (DOT) com...
Thanks Sue - good idea.

Quote:
I'm OK with obtaining and storing the EntryID for later use but could
you
help more with the syntax with Namespace.GetItemFromID and
AppointmentItem.Delete - I'm not so familar with these two contructs.

Quote:
Regards - Andy.

Quote:
"Sue Mosher [MVP-Outlook]" wrote:

Quote:
Delete it in what context? If you get the item's EntryID after saving
it
and
store that in your Access database, you can return the same item with
the
Namespace.GetItemFromID and then delete it with the
AppointmentItem.Delete
method.

Quote:
"Andy" <A... (AT) discussions (DOT) microsoft.com> wrote in message
newsB7F9858-6C2B-4E9B-A3EF-260AB285A1E8 (AT) microsoft (DOT) com...
I have successfully added an All Day appointment for tomorrow in
Outlook
from
Access using :-

Quote:
--------------

Quote:
Dim objOutlook As Outlook.Application
Dim objCalendar As Object
Dim objAppointment As Object

Quote:
Set objOutlook = New Outlook.Application
Set objCalendar =
objOutlook.Session.GetDefaultFolder(olFolderCalend ar)

Quote:
Set objAppointment = objCalendar.Items.Add
With objAppointment
.Subject = "Test"
.Start = Date + 1
.AllDayEvent = True
End With
objAppointment.Close olSave
Set objAppointment = Nothing
Set objOutlook = Nothing

Quote:
---------

Quote:
Can anyone help me with the code to delete the same appointment
using
VBA?

Quote:
Thanks.


Reply Rate this post: Text for clearing space

8 From: Andy - view profile
Date: Thurs, Jan 13 2005 7:37 am
Email: "Andy" <A... (AT) discussions (DOT) microsoft.com>
Groups: microsoft.public.outlook.program_vba
Not yet ratedRating:
show options


Reply | Reply to Author | Forward | Print | Individual Message | Show
original | Report Abuse | Find messages by this author


I eventually figured out why the deletes weren't working.

Below, when I stored the EntryID away in the database I hadn't realised
that
the default size of a text field in Access is 50 characters. The
EntryID is
much more than this (about 160 chrs) so the ID's were being truncated.
By increasing the size of the text field the ID's were stored correctly
so
when they were retieved in order to delete the appointment at a later
date,
it worked fine.
So the code was OK.


Andy.



Reply With Quote
  #4  
Old   
OzPaul
 
Posts: n/a

Default Re: Paradox, OLE, Outlook and Modify etc - 06-06-2006 , 10:31 PM



And possibly better.....

This example deletes one instance of a recurring appointment. The
example assumes that an instance of a recurring appointment occurs on
June 28, 2006, at 08:00.

Example
Visual Basic Copy CodePrivate Sub ThisApplication_Startup(ByVal sender
As Object, _
ByVal e As System.EventArgs) Handles Me.Startup

Dim calendar As Outlook.MAPIFolder = _
Session.GetDefaultFolder( _
Outlook.OlDefaultFolders.olFolderCalendar)

Dim calendarItems As Outlook.Items = calendar.Items

Dim item As Outlook.AppointmentItem = TryCast( _
calendarItems("Test Appointment"), Outlook.AppointmentItem)

Dim pattern As Outlook.RecurrencePattern = _
item.GetRecurrencePattern()

Dim itemDelete As Outlook.AppointmentItem = _
pattern.GetOccurrence(New Date(2006, 6, 28, 8, 0, 0))

If itemDelete IsNot Nothing Then
itemDelete.Delete()
End If
End Sub

C# Copy Codeprivate void ThisApplication_Startup(object sender,
System.EventArgs e)
{
Outlook.MAPIFolder calendar =
Session.GetDefaultFolder(
Outlook.OlDefaultFolders.olFolderCalendar);

Outlook.Items calendarItems = calendar.Items;

Outlook.AppointmentItem item =
calendarItems["Test Appointment"] as Outlook.AppointmentItem;

Outlook.RecurrencePattern pattern =
item.GetRecurrencePattern();
Outlook.AppointmentItem itemDelete = pattern.
GetOccurrence(new DateTime(2006,6,28,8,0,0));

if (itemDelete != null)
{
itemDelete.Delete();
}
}


Reply With Quote
  #5  
Old   
OzPaul
 
Posts: n/a

Default Re: Paradox, OLE, Outlook and Modify etc - 06-06-2006 , 10:40 PM



PS my simple code for inserting an appointment is something like this


var
ol,appt oleAuto
endVar

; other variable details deleted.... show remaining code

ol.Open("Outlook.Application")
appt=ol.CreateItem(1)
olAppointmentItem=3
appt.Subject = testType+" "+"appointment for"+" "+snme
appt.Body="Appointment for Patient from Scientist"
appt.Start=dateTime(dte) ;("15:30:00, 15/09/2006")
appt.Duration=60
appt.Location = "Restaurant" ; 'Appointment's location
appt.ReminderSet = True ; 'Set Reminder to 15 minutes

; olBusy optional values are
;olBusy 2
;olFree 0
;olOutOfOffice 3
;olTentative 1
appt.BusyStatus = 2
appt.save() ; save appointment in Outlook

;invoke(appt.AppointmentItem.Delete) does not work if appt above
exists
;appt^delete() does not work either
msgInfo("Success","Entered in Outlook Calendar")


Reply With Quote
  #6  
Old   
Liz McGuire
 
Posts: n/a

Default Re: Paradox, OLE, Outlook and Modify etc - 06-07-2006 , 10:37 AM



For the record, I have no clue. I just thought it might help someone
who did.

It's probably best to be patient, btw, it could take a while for
someone to figure this out.

Liz

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.