Can an Outlook macro trigger its built-in import functionality?
I'm trying to automate Outlook to automa开发者_如何学Gotically load an iCalendar file (.ics) when it starts. I'm aware of the hooks I need to use to arrange the timing already, I just haven't been able to find quality information about what sort of automation is possible.
Since Outlook already has the ability to import iCalendar files well enough for my purposes, I'd prefer to trigger that functionality rather than write my own parsing code. Is that possible?
Depending on what you want, the answer is you cannot do it.
If you want to "import" the ics file you cannot do it alone, you would need for example redemption see here Visual Studio Forum Because MS moves their links often here is a quote from there
“Outlook has no built-in methods to import an ICS file into a calendar item using code. However, a 3rd party library called Redemption (www.dimastr.com/redemption) does have that ability. The SafeAppointmentItem.Import function is called with a file path and item type. So if it's called with the file path where you saved the attachment and a type of 7 (olVCal) you can do what you want. “ Original link is:http://groups.google.co.uk/group/microsoft.public.office.developer.outlook.vba/browse_thread/thread/e4656ad0c5b68b89/d356ce07aeae783d?hl=en&lnk=st&q=import+.ics+file+into+outlook+by+codes#d356ce07aeae783d
So what are you options or what else can you do.
First I assume you are working in something like the application_startup event.
you could "shell" the file - which would have the same effect as double clicking on it.
see here MSDN shell with examples For this you would need the path to your ics file.
But for me in your position, I would be first trying to get the person or thing generating the ics file to change OR I would be just treating it like a text file, parsing the information (which should not be too hard given it is an expected format) and creating my own calendar item in outlook.
精彩评论