INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

COM and Automation

How to use XML (parser) to create Custom Outlook Views ? by Docpro777
Posted: 20 Aug 03

1) First, generate an appropriate custom table view manually in Outlook, Now 'Modify' it within Outlook's View Menu.

2) Create an XML file generator.prg as follows: copy the following code with Outlook OPEN, i.e.,:

#Define olFolderCalendar 9
objView = CreateView("New Calendar Table View",olFolderCalendar,0)
***
Function CreateView
Parameters strName,cnstFolderName,cnstViewType
PUBLIC objViews as Views
PUBLIC objViewCalendar as View
oOutlook = Createobject("Outlook.Application")
objXML=Createobject("MSXML2.DomDocument")

objViews = oOutlook.getnamespace("MAPI").GetDefaultFolder(cnstFolderName).Views

For Each objView In objViews
    If objView.Name=strName
        ?objView.name
        =STRTOFILE(objView.XML,'MyXMLfile')  &&the XML suffix generates the XML code file
    Endif
Endfor

3. Voila: You've just created your custom Outlook table that EVEN INCLUDES YOUR USER DEFINED FIELDS complete with properties, format(s), etc. in XML.  
Note: USER DEFINED FIELDS are practically impossible to write in XML directly.  E.g.: This is what MS Outlook generated in XML for "MyUserDefinedField" (a User Defined Field):
<column>
    <heading>MyUserDefinedField</heading>
    <prop>http://schemas.microsoft.com/mapi/string/{00020329-0000-0000-C000-000000000046}/MyUserDefinedField</prop>
    <type>boolean</type>
    <width>36</width>
    <style>text-align:center;padding-left:3px</style>
    <format>boolicon</format>
    <displayformat>3</displayformat>
</column>

4. Next, Open the (temporary) MyXMLfile itself and copy (to the clipboard) all the XML code that was generated by outlook  ...via VFP's STRTOFILE(objView.XML,'MyXMLfile') statement.  Open notepad and label your XML file as you'd wish: In this example you might label that file "objViewCalendar.XML"

5. Finally, label another program and copy this code into it:
#DEFINE olTableView    0        
=SetTableProperties("New Calendar Table View")    &&This parameter name is arbitrary
****
FUNCTION SetTableProperties
PARAMETERS strViewName
PUBLIC objViews as Views
PUBLIC objViewCalendar as View
oOutlook = Createobject("Outlook.Application")
objXML=Createobject("MSXML2.DomDocument")

objViews = oOutlook.GetNamespace("MAPI").GetDefaultFolder(9).Views  &&InBox
objViewCalendar = objViews.ADD(strViewName,olTableView,0)

objXML.load("objViewCalendar.XML")
objViewCalendar.XML = objXML.XML    &&MUST KEEP THIS

objViewCalendar.Save
objViewCalendar.Apply

It is finished.  Now just tie up any loose ends and integrate it into your COM object(s) and application.  Refine your XML file directly, save it, and/or repeat/modify some of the steps above.

Back to Microsoft: Visual FoxPro FAQ Index
Back to Microsoft: Visual FoxPro Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close