viewpoint-particle

Author Topic: mapi mLogOn question  (Read 122 times)

domvalle@comcast.net

  • Newbie
  • *
  • Posts: 21
mapi mLogOn question
« on: January 30, 2020, 07:19:03 am »
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

  • Newbie
  • *
  • Posts: 21
Re: mapi mLogOn question
« Reply #1 on: January 30, 2020, 07:48:48 am »
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

  • Tech Support
  • *****
  • Posts: 3210
    • WinBatch
Re: mapi mLogOn question
« Reply #2 on: January 30, 2020, 08:09:19 am »
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

  • Newbie
  • *
  • Posts: 21
Re: mapi mLogOn question
« Reply #3 on: January 30, 2020, 09:37:08 am »
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

  • Tech Support
  • *****
  • Posts: 3210
    • WinBatch
Re: mapi mLogOn question
« Reply #4 on: January 30, 2020, 01:50:32 pm »
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

  • Newbie
  • *
  • Posts: 21
Re: mapi mLogOn question
« Reply #5 on: January 31, 2020, 06:18:53 am »
THANKS! That example was helpful...
I replaced the
 . . . myItem = myOlApp.CreateItem(olAppointmentItem)
with
 . . . myItem = objFolder.Items.Add(olAppointmentItem)
 and it worked!!!!