Ok

Uancel

Figure 16.27 - The SharePoint Portal Server COM Add-in publishes attachments to a SharePoint Portal Server Documents folder
Figure 16.28 - Send a reply message to the sender to share the publication results

In order for the SharePoint Portal Server COM Add-In to function correctly, your SharePoint Portal Server workspace coordinator should assign you the author role or higher.

To add attachments to a Document folder

1. Open the message containing the attachments you want to publish.

2. Select Publish Attachments on the File menu.

3. Enter the URL of a SharePoint Portal Server Documents folder in the Folder URL edit box. The next time you publish attachments, the COM Add-in will remember the URL for the folder.

4. Select one or more attachments in the Attachments list box. Use Ctrl+Click to select multiple attachments if necessary.

5. Check the Prompt For Document Properties box if you want to be prompted for document properties such as Title, Author, Keywords, and Description.

6. Check the Reply With Publication Results if you want to send a reply message to the sender informing him or her of publication results.

8. If you elected to complete the Document Properties dialog box, enter Document Properties and click OK.

9. If you elected to reply with publication results, type a message If required and click Send. SharePoint Portal Server COM Add-In Code

The code for the SharePoint Portal Server COM Add-In Is straightforward. When the Newlnspector event fires, a Mallltem object Is Instantiated. Because this Mallltem object (named objMailltem ) Is declared using the WithEvents keyword In the declarations of the OutAddln class, you can trap Item-level events on objMailltem. In this case, the Important Item-level event Is the Open event. In the Open event, the Publish Attachments menu Item Is added to the File menu as follows:

Private Sub objMailltem_Open(Cancel As Boolean) Dim cbFile As Office.CommandBar

Set cbFile = objMailltem.Getlnspector.CommandBars.ltem("File") On Error Resume Next

Set cbbSPPS = cbFile.FindControl(Tag:="SPPS Publish Attachments") If cbbSPPS Is Nothing Then Set cbbSPPS = _ cbFile.Controls.Add(Type:=msoControlButton, _ Parameter:="SPPS Publish Attachments", Before:=7, Temporary:=True) With cbbSPPS

.Parameter = "SPPS Publish Attachments" .Faceld = 258

.Style = msoButtonlconAndCaption .Caption = "Publish Attachments..." .Tag = "SPPS Publish Attachments" .BeginGroup = False End With End If

If objMailltem.Attachments.Count = 0 Then cbbSPPS.Visible = False Else cbbSPPS.Visible = True End If End Sub

When the Close event for objMailltem fires, the Publish Attachments command bar control Is removed from the File menu. Here's the code:

Private Sub objMailltem_Close(Cancel As Boolean) On Error Resume Next Dim cbFile As Office.CommandBar Set cbFile = objMailltem.Getlnspector.CommandBars.ltem("File") Set cbbSPPS = cbFile.FindControl(Tag:="SPPS Publish Attachments") cbbSPPS.Delete End Sub

That's all there Is to the code In the OutAddln class of the COM Add-In. The other Important code Is contained In the frmPubllsh form. When this form loads, the Initialize event fires. The Initialize event for a UserForm Is equivalent to the Load event for a Visual Basic form. The Initialize procedure checks for registry values that supply a folder URL and determine whether the Prompt For Document Properties and Reply With Publication Results boxes are checked. The procedure then uses the Attachments collection to populate the Attachments list box.

Private Sub UserForm_lnitialize()

Dim i, intCount As Integer

Dim strURLAs String

Dim blnPrompt, blnResults As Boolean

On Error Resume Next strURL = _

GetKeyValueEx(HKEY_CURRENT_USER, gstrRegKey, "URL") If strURL <> "" Then txtURL = strURL blnPrompt = _

GetKeyValueEx(HKEY_CURRENT_USER, gstrRegKey, "Prompt") If blnPrompt Then chkPrompt.Value = True Else chkPrompt.Value = False End If blnResults = _

GetKeyValueEx(HKEY_CURRENT_USER, gstrRegKey, "Results") If blnResults Then chkResults.Value = True Else chkResults.Value = False End If End If

IstAttachments. Clear

'objltem is declared as a form-level variable Set objltem = golApp.Activelnspector.Currentltem intCount = objltem.Attachments.Count For i = 1 To intCount

If objltem.Attachments.ltem(i).Type = olByValue Then IstAttachments.Addltem _ objltem.Attachments. Item(i). Display Name End If Next End Sub

After the form has been loaded, the code behind the cmdOK button does the actual work of publishing documents to SharePoint Portal Server. This code derives from the PublishSharePoiritDocumerit method in the Outlook Shared Activities Add-in discussed earlier. The IstAttachments ActiveX control supports a selected property that lets you determine whether the attachment has been selected for publication. Once the publication is complete, a reply message is prepared for the sender of the original message. This message informs the sender of the URLs for the published documents on SharePoint Portal Server. Notice that you must use the Replace function to convert the SharePoint URL to a canonical URL in order for the URL to work correctly in the body of the reply message. Canonical URLs do not contain spaces. The code for cmdOK is shown here:

Private Sub cmdOK_Click()

Dim oFolder As New PKMCDO.KnowledgeFolder

Dim oDoc As PKMCDO.KnowledgeDocument

Dim oStream As ADODB.Stream

Dim objMsg As Mailltem

Dim strPath, strURL, strDisplayName, strMsg, strError As String Dim i As Integer On Error Resume Next If txtURL = "" Then MsgBox "You must supply a URL to SPPS folder.", vblnformation Exit Sub End If

On Error Resume Next oFolder.DataSource.Open txtURL If Err Then

MsgBox "Could not open the URL:" & vbCrLf & txtURL, vbCritical txtURL.SelStart = 0 txtURL. SelLength = Len(txtURL) txtURL.SetFocus Exit Sub Else 'Hide this form Me.Hide frm Wait.Show Do Events

'Persist settings to registry SetKeyValue HKEY_CURRENT_USER, _

gstrRegKey, "URL", txtURL, REG_SZ SetKeyValue HKEY_CURRENT_USER, _

gstrRegKey, "Prompt", Abs(chkPrompt.Value), REG_DW0RD SetKeyValue HKEY_CURRENT_USER, _

gstrRegKey, "Results", Abs(chkResults.Value), REG_DW0RD 'Create message for Post Item strMsg = vbCrLf & vbCrLf & _

"—SharePoint Portal Server Publication Results-----" & _

vbCrLf & "Source Message:" & objltem.Subject & vbCrLf & _ "Received:" & objltem.ReceivedTime & vbCrLf & vbCrLf & _ "Document Title/URL:" & vbCrLf & vbCrLf End If

'Iterate over attachments For i = 1 To IstAttachments.ListCount 'Only publish selected items If lstAttachments.Selected(i -1) = True Then strDisplayName = objltem.Attachments.ltem(i).DisplayName strPath = GetTempDir& objltem.Attachments.ltem(i).FileName objltem.Attachments.ltem(i).SaveAsFile strPath Set oDoc = New PKMCDO.KnowledgeDocument 'Open binary stream Set oStream = oDoc.OpenStream oStream.Type = adTypeBinary oStream.SetEOS

'Load the attachment from the temp folder oStream.LoadFromFile strPath oStream.Flush

Set oStream = Nothing

'Delete the attachment from temp folder

Kill strPath strURL = txtURL & "/" & strDisplayName 'Save to URL

If chkAuthenticateAs = True Then oDoc.DataSource.SaveTo _ SourceURL:=strURL, _ Username:=txtUserName, _ Password:=txtPassword

Else oDoc.DataSource.SaveTo (strURL) End If

'Check for errors If Err = 0 Then

If chkPrompt.Value = True Then With frm Properties

.Caption = strDisplayName & " Properties" .txtAuthor = oDoc.Author .txt Title = oDoc.Title

.txtKeywords = GetKeywords(oDoc.Keywords) .txtDescription = oDoc.Description .Show 1 Do Events End Wth

'If True, set oDoc properties If blnProperties Then oDoc.Author = frmProperties.txtAuthor oDoc.Title = frmProperties.txtTitle If frmProperties.txtKeywords <> "" Then 'Changes txtKeywords into array o Doc. Keywords = _ SetKeywords(frmProperties.txtKeywords) End If oDoc.Description = frmProperties.txtDescription oDoc.DataSource.Save End If

Unload frmProperties Do Events End If strMsg = strMsg & oDoc.Title & vbCrLf_ & Replace(oDoc.DataSource.SourceURL,"", "%20")_ & vbCrLf& vbCrLf

Else 'Error occurred strError = strError & strDisplayName & vbCrLf _ & Replace(strURL,"", "%20") & vbCrLf_ & "Error Number:" & Err.Number & vbCrLf _ & "Error Description:" & Err.Description _ & vbCrLf & vbCrLf End If

'Checkin and publish

Dim oVersion As New PKMCDO.KnowledgeVersion oVersion.Checkin strURL oVersion.Publish strURL Set oVersion = Nothing Set oDoc = Nothing End If Next

If chkResults = True Then If strError <> "" Then strMsg = strMsg & strError End If

'Create a reply message Set objMsg = objltem.Reply objMsg. Body Format = olFormatRichText objMsg. Body = strMsg objMsg. Display End If

Unload frmWait Unload Me End Sub

SharePoint Development Opportunities

SharePoint Portal Server offers a wealth of development opportunities on its own or in conjunction with Office XP applications such as Outlook 2002. The Web Storage System provides a solid platform for building collaborative applications. It's up to developers like you to create outstanding solutions for the SharePoint Portal Server platform. Unlike development on the Exchange 2000 Server platform-which uses server-based technologies such as Web Storage System forms (SP1 or later), event sinks, and the Exchange 2000 workflow engine-SharePoint Portal Server development occurs on both the client and the server. PKMCDO operates as an object library on both client and server computers. Use the version of the SharePoint Portal Server SDK supplied on the companion CD to broaden your knowledge of the PKMCDO Object Model and the best practices for SharePoint Portal Server development. Based upon what you now know about Outlook 2002 and SharePoint Portal Server, you can begin to evaluate integrated Outlook and SharePoint Portal Server solutions for your own organization.

Where to Go from Here

Many resources can help you deepen your understanding of the material in this chapter. I'll list some of the most helpful ones

Microsoft Knowledge Base Articles Microsoft Knowledge Base articles are available on the Web at

http://support.microsoft.com/support. Also see "Using Outlook with SharePoint Portal Server (Chapter 16) KB Articles" in the

Microsoft Web Sites folder under the Help And Web Sites folder on the companion CD.

SharePoint Portal Server Articles and Resources

• See the item entitled "SharePoint Portal Server Technical Articles" in the Help folder under the Help And Web Sites folder on the companion CD.

• The SharePoint Portal Server SDK is available at http://www.microsoft.com/sharepoint/downloads/tools/SDK.asp.

• See the white paper, "SharePoint Portal Server as a Collaborative Solution Platform," at http://msdn.microsoft.com/librarv/default. asp? URL=/librarv/techart/Tahoe. htm.

• See the "Web Storage System Schema Usage and Best Practice Guide" at http://msdn.microsoft.com/librarv/default. asp? URL=/librarv/techart/Wssschemause. htm.

Books on Web Storage System Development

Gomez, Alex; Jamison, Scott; Wesolowski, George. Developing Applications with Exchange 2000: A Programmer's Guide. Boston, MA: Addison Wesley, 2001.

Martin, Mindy. Programming Collaborative Web Applications with Microsoft Exchange 2000 Server. Redmond, WA: Microsoft Press, 2000.

Rizzo, Thomas. Programming Microsoft Outlook and Microsoft Exchange, Second Edition. Redmond, WA: Microsoft Press, 2000.

Randy Byrne

A veteran developer for Microsoft Outlook, Randy Byrne is the President and CEO of Micro Eye, Inc., a Microsoft Certified Partner specializing in collaborative application development using Microsoft Exchange and Outlook. As a Microsoft Most Valued Professional (MVP) for Outlook, he has extensive experience with the concerns of the Outlook development community. He received his Bachelor's degree from Yale University and a graduate degree from the University of California at Berkeley. A resolute fan of the Outlook Object Model, he contributes regularly to Exchange and Outlook magazine. He is a speaker at numerous industry conferences, including Microsoft TechEd, the Microsoft Exchange Conference, and the Exchange/Outlook Developer's Summit. Micro Eye, Inc., is located in the Sacramento area of Northern California.

About This Electronic Book

Every effort has been made to ensure that the text of this eBook matches the text of the paper version as closely as possible. For usability reasons, formatting changes may have been made to the eBook version.

Tell Us What You Think

We need to hear from you regarding your experience with our eBooks. Tell us what you like, don't like; which features you use, and which features you would like to see in future versions of our eBooks. Send your comments to [email protected]. Please note that technical support is not offered through this alias.

Create a List of Favorite Topics

1. Locate the topic you want to make a favorite topic.

2. Click the Favorites tab, and then click Add.

To return to a favorite topic, click the Favorites tab, select the topic, and then clickDisplay. If you want to rename a topic, select the topic, and then type a new name in the Current topic

To remove a favorite topic, select the topic and then click Remove.

External Links

This eBook may contain links to Web sites. All hyperlinks within the text were valid at the time this eBook was published. Due to the nature of the World Wide Web, we cannot guarantee that all links to Web sites are still valid after the release date of the eBook

Enlarge Graphics

Many of the graphics shown in this book are quite large. To improve the readability of the electronic version, reduced versions of these graphics are shown in the text. To see a full-size version, click on the reduced graphic.

Use Accessibility Shortcut Keys

The following keyboard shortcuts can be used for navigation.

For more information about accessibility features and services, visit the Microsoft Accessibility Web site. For the Library:

To

Press

Close the eBook.

ALT+F4

Switch between the eBook and other open windows.

ALT+TAB

Print a topic.

Right-click in the Topic pane.

Move back to the previous topic.

ALT+LEFT ARROW

Move forward to the next topic (provided you have viewed it just previously).

ALT+RIGHT ARROW

Refresh the topic that appears in the Topic pane (this is useful if you have linked to a Web page).

0 0

Post a comment