Microsoft Outlook 2007 Programming

Jumpstart for Administrators and Power Users

Sue Mosher


e-books shop
Microsoft® Outlook 2007
Programming:

Jumpstart for Administrators
and Power Users


Acknowledgments
I’ve already thanked the readers of my previous books for their input. Also
crucial to the shaping of this book were the questions and comments from
the thousands of other people with whom I’ve exchanged code ideas in the
discussion forums at http://www.outlookcode.com and in Microsoft’s newsgroups.

I owe a special debt to all the Outlook MVPs (“Most Valuable Professionals”
recognized by Microsoft for great practical knowledge and grace
under fire when helping other users). Eric Legault played a pivotal role as
tech editor and contributor of code sample and illustration ideas (but if you
find any code that won’t run, it’s my fault). I also need to single out Ken
Slovak, Dmitry Streblechenko (developer of Outlook Spy and Redemption),
and Michael Bauer. Word MVP Cindy Meister ably updated an earlier
Word printing sample to use the new content controls in Word 2007.

At Microsoft, I can’t thank Outlook extensibility program manager (and
former MVP) Randy Byrne enough for the many questions he fielded and
details he provided about Outlook 2007’s new capabilities. Randy and his
colleagues Peter Allenspach and Ryan Gregg, who taught me all I know
about form regions, are largely responsible for making Outlook 2007 the
most programmable version ever. I’m also grateful for input from Bill Jacob
and especially Angela Wong for the effort she put into Outlook’s developer
documentation. Among people at other organizations who inspired and
instructed were Simon Breeze and Helmut Obertanner.

I must thank Theron Shreve for letting me take my Outlook book ideas
and run with them. All the gang at Digital Press contributed their fast-track
expertise so that this book could include late-breaking material that didn’t
come to light until after the official launch of Office 2007. Final production
was again in the capable hands of Alan Rose and Lauralee Reinke.

As always, I couldn’t have finished this book without the encouragement
of my family, Robert and Annie, who endured my frustrations at running
beta software and smiled at my little coding triumphs. Annie helped get
much of the material from my previous Outlook programming book ready
for revision, making it possible to finish this book just a couple of months
after Outlook 2007 was released. She also gets an extra nod for the proofreading
and formatting assistance that she provided for my earlier Outlook
2003 book for Digital Press.

Finally, I thank God for the opportunity to share this knowledge and

help people connect with each other.


Introduction
Microsoft Office Outlook 2007, the sixth version of Microsoft’s premier
email and collaboration application, has arrived at a fork in the road. On one
side are the professional developers who use Visual Studio .NET to produce
add-ins that integrate tightly with Outlook. On the other side are the smart
end-users and rushed administrators who want to bend Outlook to their will
and work (or play) more productively. As the Office 2007 beta was getting
under way, K. D. Hallman, Microsoft’s General Manager for Visual Studio
Tools for Office, estimated that there were 3–4 million professional Office
developers and 16 million non-professional Office developers.

I wrote this book for the latter group—mainly for people who don’t program
Outlook as a full-time job. You are the people who confess in the
newsgroups that you’ve done little programming, but you’re willing to try.
You are the people who make me smile when you come back a week later
and proclaim, “I did it! Hooray!” You will find here all the information you
need to get started programming with Outlook VBA and custom forms, or
to build upon the skills you already have so that you can take advantage of
the many new programming features in Outlook 2007.

Yet, I didn’t forget the professional developers. Pro-level books on Outlook
development need to explain add-in architectural issues and highlight
the essential new programming features in Outlook 2007, such as form
regions and the PropertyAccessor object. Amid all of this great material,
there probably won’t be room to review basics such as how to return a particular
item or folder, or how to use the WordEditor object to manipulate
the text and formatting in the body of an Outlook item. Those essential
building blocks of Outlook programming form the core of this book, and I
invite pro-developers to skip the VBA basics chapters (be kind to the newbies!)
and jump straight into Part IV, “Fundamental Outlook Coding Techniques.”
You will also find in this book the essentials of creating and
managing legacy custom Outlook forms if your organization isn’t yet ready
to migrate its forms applications to form regions.

I have learned a lot from my readers in the four years since Microsoft
Outlook Programming: Jumpstart for Administrators, Power Users, and Developers
was published, and I am very grateful for your input. You’ve told me
what code worked and what you wanted to know more about. You’ve suggested
ways to organize the book better. I hope that I’ve listened well and
that you’ll find this update useful. (If you are still using Outlook 2003, the
earlier book will be more relevant to you than this book, in which much of
the content applies only to Outlook 2007.)

I think it’s important to say what this book is not: It is not a complete
reference to the Outlook object model, nor is it a guide to building add-ins
for installation in the enterprise or for distribution to commercial customers.
(Excellent resources area available on both those topics; check my web
site at http://www.outlookcode.com for links and downloads of all the code
samples in this book.) This book is also not a guide to writing .NET code.
All the samples are in VBA or VBScript, which are the languages used by
power-users and administrators. Since many professional Outlook developers
use VBA for light prototyping, I think that’s still the right language for
showing Outlook basics to the maximum number of people.

Conventions used in this book
This book uses different typefaces to differentiate between code and regular
text and to help you identify important concepts:
Code statements and the names of programming elements appear in
monospace font:
Item.BodyFormat = olFormatRichText
Placeholders for various expressions appear in monospace italic font.
You should replace the placeholder with the specific value that your specific
application of the code requires.

Text that you type is presented within quotation marks. New terms
appear in italics.

The Notes, Tips, and Cautions scattered throughout the book try to call
attention to information that will help you become a better Outlook programmer.

A Note presents interesting information related to the surrounding
discussion. A Tip offers advice or teaches an easier way to do something.
A Caution advises you of potential problems and helps you to steer clear of disaster.


Table of Contents
Introduction xi
Acknowledgments xiii
1 What You Can Do with Outlook 2007
1.1 Why program with Outlook? 2
1.2 Outlook programming tools 2
1.3 How to start 9
1.4 Key Outlook programming components 11
1.5 Showing developer commands 11
1.6 Summary 13
Part I Basic Outlook VBA Design
2 The VBA Design Environment
2.1 VBA: The basics 15
2.2 VBA windows 18
2.3 Getting help in VBA 24
2.4 Working with VBA projects 26
2.5 Summary 29
3 Building Your First VBA Form
3.1 Understanding Outlook birthdays and anniversaries 31
3.2 Step 1: What controls do you need? 32
3.3 Step 2: Create the form 33
3.4 Step 3: Add user input controls 36
3.5 Step 4: Add command buttons 38
3.6 Step 5: Plan the next development stage 45
3.7 More on VBA form controls 45
3.8 Summary 55
Part II Basic Outlook Form Design
4 Introducing Outlook Forms
4.1 Understanding the two types of custom forms 57
4.2 Starting the forms designer 59
4.3 The six standard Outlook forms 60
4.4 When to use which form 74
4.5 Working in the forms designer 76
4.6 Saving forms and ending a design session 78
4.7 Creating your first custom contact form 81
4.8 Summary 94
5 Introducing Form Regions
5.1 Understanding form regions 95
5.2 Controls for form regions 97
5.3 Creating your first form region 100
5.4 Registering and deploying form regions 103
5.5 Limitations of form regions 110
5.6 Other ideas for form regions 110
5.7 Summary 111
6 Extending Form Design with Fields and Controls
6.1 Understanding fields versus controls 113
6.2 Creating user-defined fields 114
6.3 Adding and removing fields on Outlook forms 122
6.4 Using form controls 128
6.5 Laying out compose and read pages 137
6.6 Summary 139
Part III Writing VBA and VBScript Code
7 Outlook Code Basics
7.1 Understanding when VBA code runs 141
7.2 Writing VBA code 152
7.3 Writing VBScript code for Outlook forms 159
7.4 Referring to Outlook item properties 168
7.5 Writing other Outlook automation code 171
7.6 Summary 175
8 Code Grammar 101
8.1 Option Explicit 177
8.2 Declaring variables and constants 179
8.3 Writing procedures 188
8.4 Working with expressions and functions 198
8.5 Working with strings 200
8.6 Working with dates and times 206
8.7 Using arrays, dictionaries, and the Split() and Join() functions 216
8.8 Controlling program flow 222
8.9 Providing feedback 234
8.10 Getting user input 240
8.11 Working with files and other objects 249
8.12 Summary 258
9 Handling Errors, Testing, and Debugging
9.1 Understanding errors 261
9.2 Testing and debugging in VBA 269
9.3 Debugging Outlook form VBScript code 277
9.4 Summary 287
Part IV Fundamental Outlook Coding Techniques
10 Outlook Programming Basics 
10.1 Introducing the Outlook object model 289
10.2 Outlook object and collection code techniques 295
10.3 Understanding Outlook security 302
10.4 Summary 312
11 Responding to Outlook Events in VBA
11.1 Application object events 314
11.2 Writing handlers for other object events 329
11.3 Explorers and Explorer events 333
11.4 Inspectors and Inspector events 338
11.5 Folders, Folder, and Items events 343
11.6 Processing incoming mail 347
11.7 Using the Application.Reminder and Reminders events 356
11.8 Summary 369
12 Coding Key Custom Form Scenarios
12.1 Working with Outlook item events 371
12.2 Responding to user input on forms 377
12.3 Handling form and control state issues 391
12.4 Summary 400
13 Working with Stores, Explorers, and Folders
13.1 Information store concepts 401
13.2 Information store techniques 403
13.3 Working with Explorers 410
13.4 Accessing folders 412
13.5 Working with folders 434
13.6 Summary 442
14 Using PropertyAccessor and StorageItem
14.1 Using the PropertyAccessor object 446
14.2 Using the StorageItem object 458
14.3 Summary 462
15 Working with Inspectors and Items
15.1 Working with Inspectors 464
15.2 Creating items 467
15.3 Accessing items 474
15.4 Using the Table object 484
15.5 Using Item methods 492
15.6 Summary 500
16 Searching for Outlook Items
16.1 Introduction to Outlook search methods 501
16.2 Building search strings 503
16.3 Using Items.Find and Items.Restrict 521
16.4 Using Table search techniques 525
16.5 Using Explorer.Search 527
16.6 Using Application.AdvancedSearch 530
16.7 Summary 541
17 Working with Item Bodies
17.1 Basic item body techniques 543
17.2 Parsing text from a message body 545
17.3 Adding text to an item 547
17.4 Creating a formatted message 551
17.5 Using WordEditor 554
17.6 Working with Outlook signatures 563
17.7 Summary 568
18 Working with Recipients and Address Lists 
18.1 Key recipient and address list objects 570
18.2 Understanding address lists 571
18.3 Working with item recipients 577
18.4 Reading Recipient and AddressEntry information 584
18.5 Reading free/busy information 588
18.6 Showing the Select Names dialog 594
18.7 Summary 601
19 Working with Attachments
19.1 Understanding Outlook attachments 603
19.2 Adding attachments to Outlook items 606
19.3 Working with attachments on existing items 608
19.4 Summary 618
20 Common Item Techniques
20.1 Using custom message forms 620
20.2 Working with voting buttons and other custom actions 626
20.3 Sending a message with a specific account 637
20.4 Creating a meeting request 639
20.5 Assigning a task 641
20.6 Linking Outlook items 642
20.7 Creating an annual event from a custom date field 649
20.8 Summary 658
Part V Finishing Touches
21 Deploying and Managing Outlook Forms
21.1 Understanding Outlook forms architecture 660
21.2 Managing Outlook forms 668
21.3 Managing custom fields 679
21.4 Deploying Outlook forms 683
21.5 Troubleshooting Outlook forms 690
21.6 Summary 693
22 Rules, Views, and Administrator Scripting Tasks
22.1 Why Outlook scripting is a challenge 696
22.2 Internal scripting with custom message forms 697
22.3 Working with Outlook rules 706
22.4 Managing folder views 714
22.5 Internal scripting with folder home pages 728
22.6 Summary 735
23 Menus, Toolbars, and the Navigation Pane
23.1 Programming Outlook menus and toolbars 737
23.2 Working with context menus 750
23.3 Working with the navigation pane and other Explorer panes 763
23.4 Summary 770
24 Generating Reports on Outlook Data
24.1 Built-in report techniques 771
24.2 Coding reports with the Outlook object model 777
24.3 Sending output to Microsoft Excel 778
24.4 Sending output to Microsoft Word 788
24.5 Using Word to build an invoice report 792
24.6 Summary 808
Index 809


Screenshot

e-books shop

Purchase Now !
Just with Paypal



Product details
 Price
 Pages
 841 p
 File Size
 13,034 KB
 File Type
 PDF format
 ISBN
 978-1-55558-346-0 
 Copyright
 2007, Elsevier Inc
  ●▬▬▬▬▬❂❂❂▬▬▬▬▬●
●▬▬❂❂▬▬●
●▬❂▬●

═════ ═════

Loading...
DMCA.com Protection Status