mapi mLogOn question

Started by domvalle@comcast.net, January 30, 2020, 07:19:03 AM

Previous topic - Next topic

domvalle@comcast.net

We are looking to post an appointment to a shared calendar.
We found the article 'Writing Appointments to Outlook' which works except when the user has Outlook already open.
Then it posts the appointment to the users cal instead.
If we terminate Outlook and use mLogOn("Applications Profile") then it works.
Is there another way to reference a shared calendar without naming second profile?
In this case the default user profile does have permissions to this cal...

domvalle@comcast.net

Interesting...
I exported the cal to an .ics file and found this:
   X-WR-RELCALID:{0000013D-8BE3-54B6-434C-A8F50B0D2554}
   X-WR-CALNAME:Applications
Otherwise I have no idea...

td

There are multiple articles about MAPI in the Tech Database.  You could consider perusing there for ideas.  Here is a link to one such article:

https://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/nftechsupt.web+WIL~Extenders/MAPI+MAPILogonEx~vs.~MAPILogon.txt
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

domvalle@comcast.net

Yes... I also found this one: OLE and OUTLOOK read mail other than inbox
using this example I was able to navigate and display the shared cal but the createItem still posts to the default.

AddExtender("WWMAP44I.DLL")
mhdl=mLogOn("Applications") ;gets handle
mailid="";important to initialize
olAppointmentItem=1
olByReference=4
recuring=0
olFolder="Applications"
myFolder= "Calendar" 

myOlApp = ObjectCreate("Outlook.Application")
objNameSpace = myOlApp.GetNamespace("MAPI")
objFolder1 = objNameSpace.Folders(olFolder);
objFolder=objFolder1.Folders(myFolder);

objFolder.Display                                                        ;-->this displays the shared cal we want...
pause("Test", "test" )

myItem = myOlApp.CreateItem(olAppointmentItem) ;-->but this sill posts to the users default cal
                                                                                  ; tried replacing myOlApp with objFolder but it will error
myItem.Subject = "Test Client Subject"
myItem.Location = "TriVin License Expirations"
myItem.Body = "This clients License Expirations"
myItem.BusyStatus = 3 ;0 Free , 1 Tentative, 2 Busy, 3 Out of office
;myItem.RecurrencePattern = 0 ;0 Daily
year=ItemExtract(1,TimeYmdHms ( ),":")
month=ItemExtract(2,TimeYmdHms ( ),":")
date=ItemExtract(3,TimeYmdHms ( ),":")
hour=ItemExtract(4,TimeYmdHms ( ),":")
minute=ItemExtract(5,TimeYmdHms ( ),":")+15
If minute>=60
    minute=minute-60
    hour=hour+1
EndIf
If hour>=24
    hour=hour-24
    day=day+1
EndIf
myItem.Start = StrCat(date,"/",month,"/",year," ",hour,":",minute,":00")
myItem.Duration = 90
type = olByReference
If recuring==1 Then myItem.Display
Else myItem.Save

ObjectClose(myItem)
ObjectClose(myOlApp)

mLogOff(mhdl)
Message("","DONE, Appointment created...")

Exit

td

Perhaps review this VBA discussion.  If it proves useful, the code should translate to WinBatch in a straight forward manor:

https://stackoverflow.com/questions/37353404/how-to-add-an-appointment-to-a-shared-calendar-in-outlook
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

domvalle@comcast.net

THANKS! That example was helpful...
I replaced the
. . . myItem = myOlApp.CreateItem(olAppointmentItem)
with
. . . myItem = objFolder.Items.Add(olAppointmentItem)
and it worked!!!!