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

outlook automation

Status
Not open for further replies.

lclock

Programmer
Jan 24, 2009
15
IT
hi, does anybody know if it's possible to create a new appointment in an outlook specific calendar (not the default one)?
I want to transfer schedueled activities from my crm developed with vfp to outlook, but i want to transfer the activities in a calendar that is connected with my outlook.com calendar so that i can have all info in my wp8 calendar.
Thank you
Lclock
Luca Colombo
 
I have not done this myself, so I cannot advise you with first-hand knowledge, but in the book:
Microsoft Office Automation with Visual FoxPro

In Chapter 12 - on page 341 I find: Adding appointments and tasks

While the book was written about a previous version of Office & Outlook, it might be worth your while getting a copy for yourself.

Good Luck,
JRB-Bldr
 
The typical outlook automation for appointments goes

#DEFINE olAppointment 26
oOutlook = CreateObject("Outlook.Application")
oAppointment = oOutlook.createitem(olAppointment)

I'm sure you know and this doesn't help you further, as that generates an appointment in the default user's default calendar.

But you can bring this together with the typical way to login to another account in outlook:
oSession = CreateObject('MAPI.Session')
oSession.Logon() && Unless you know the profile, this will prompt you to select one.

All this and much more is shown in faq184-1769

Bye, Olaf.
 
To add to this:

MAPI.Session is typically removed from newer Windows Versions. Still many mail clients offer the MAPI API, and so there is an internal way to get at the MAPI namespace:

oOutlook = CreateObject("Outlook.Application")
oMapi = oOutlook.GetNamespace("Mapi")
oMapi.Logon()

And once your're logged in to a profile other than the default, you can also add to that profile's Calendar, Mailfolders, Adressbook etc.

Bye, Olaf.
 
Hi, I've solved!
The problem was the right identification of the folder where add appointment item.
I was looking for the outlook.com calendar, but i've stopped my research when i found the outlook.com folder, instead i've to go into that, looking for the calendar folder and there add the new item.
Use a code like this
oOutlook = CREATEOBJECT('outlook.application')
oNameSpace = oOutlook.getnamespace('MAPI')
myitems = oNameSpace.Folders(5).Folders(5).items && this point to my specific calendar
newappointment =itc.Add(APPOINTMENTITEM)
...
...
thank's all
 
>myitems = oNameSpace.Folders(5).Folders(5).items

This seems to me to be very specific for your current outlook profile. If you add a further calendar or addressbook or whatever, the calendar currently being Folder(5) may not stay at position 5 in the collection of folders.

What I found is, that you can also adress folders by names:

Code:
oOutlook = CreateObject("Outlook.Application")
oNameSpace = oOutlook.GetNamespace("MAPI")
oRecipient = oNameSpace.CreateRecipient("Administrator") && or another user name
oSharedFolder = oNameSpace.Folders("Public Folders").Folders("Favorites").Folders("Your Calendar")

Something like that.

Bye, Olaf.
 
Hi Olaf, you are absolutly right. I wrote 5 just to simplify.
I was thinking about a loop on folders to find the right one , cause i didn't know you can reference it by name, that's very usuful for me!
Thank you
Luca
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top