Welcome to MSDN Blogs Sign in | Join | Help

Microsoft Office 2010 beta is available to download

I am very excited to share that Microsoft announced the public beta release of Office 2010, SharePoint Server 2010, Visio 2010, Project 2010, Office Web Apps for business customers, and Office Mobile 2010.

If you are developing application based on Outlook; then here are few links related to developing applications for Outlook 2010:

If you are looking for resources to learn more about Office 2010. Then the Office 2010 Developer Workshop includes videos and presentations @ Office 2010 Workshop. This content is designed to help you get started developing solutions, from Add-ins to full featured Office Business Applications (OBAs), using Visual Studio 2010 with Office 2010 and SharePoint 2010 as the core platform.

So, what are you waiting for? hit the road with Office 2010 Developer Roadmap.

And to complement it we can download Microsoft Visual Studio 2010 Professional Beta and refer to

Visual Studio 2010 - What's New in Office Development as well.

Enjoy Learning!!!

Exchange Server 2007 SP2 Update Rollup1 is available to download

Exchange Server 2007 SP2 Update Rollup 1 is available to download @ Download the Exchange2007-KB971534-EN package now.

Update Rollup 1 for Exchange Server 2007 Service Pack 2 (SP2) resolves issues that were found in Exchange Server 2007 SP2 since the software was released. This update rollup is highly recommended for all Exchange Server 2007 SP2 customers. For the details related to the issue fixed by it refer to Description of Update Rollup 1 for Exchange Server 2007 Service Pack 2.

 

If you are developing application based on Exchange Web Services then following are the issues fixed by Update Rollup 1 for Exchange Server 2007 Service Pack 2 (SP2):

  • 973868 A delegate cannot cancel meetings in the organizer's calendar by using Exchange Web Service (EWS)
  • 973307 An application that uses Exchange Web Services returns an exception on an Exchange Server 2007 server
  • 972009 E-mail messages cannot be retrieved by an Exchange Web Service (EWS)-based application if there are invalid control characters in the text body of the e-mail message

So, if you are on Exchange Server 2007 SP2; I would highly recommend you to download and install Update Rollup 1 to fix the know issued with Exchange Server 2007 SP2.

Exchange Web Services Managed API and EWS Editor is available!

If you are developing using Exchange Web Services Managed API then now you can download @ Microsoft Exchange Web Services (EWS) Managed API 1.0

The Microsoft Exchange Web Services (EWS) Managed API 1.0 provides a managed interface for developing client applications that use Exchange Web Services. The EWS Managed API simplifies the implementation of applications that communicate with Microsoft Exchange Server 2007 Service Pack 1 (SP1) and later versions of Microsoft Exchange. Built on the Exchange Web Services SOAP protocol and Autodiscover, the EWS Managed API provides a .NET interface to EWS that is easy to learn, use, and maintain.

Moreover, If you are looking for sample application developed using Exchange Web Service Managed API then EWS Editor is a great resource to have. Read more details about EWSEditor and download it from Matt’s post @ Announcing EWSEditor 1.5! Here are the few points which I really liked about it:

1. Demonstrate the Exchange Web Services Managed API functionality and simplicity to developers through its source code.
2. Demonstrate the Exchange Web Services SOAP traffic used to perform actions initiated through an explorer user interface.
3. Assist non-developers in debugging and understanding Exchange stores by exploring items, folders, and their properties in depth. “

EWS rocks!

Issue accessing Public Folder Store using CDO 1.2.1 for Outlook 2007

If you are using InfoStores collection of CDO 1.2.1 for Outlook 2007 to access Public Folder store and not able to get reference to Public Folder store then here is the explanation of the design change in CDO 1.2.1 from SGriffin’s post@Outlook 2007, Public Folders, MAPI and You.

Basically, Outlook 2007's version of the Exchange provider, emsmdb32, doesn't automatically add the Public Folder store to the message store table of a new profile. Instead, it waits until a successful connection has been made to the Exchange server. If it then detects that the public folders are available, it updates the profile and sends a table notification indicating the availability of Public Folders. This is a change from previous versions of Outlook and from Exchange's version of the provider. We made this change to better support Exchange 2007's Public Folder-less environments.

Here is the vbscript sample code snippet to repro the issue:

NOTE: Following programming examples is for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This sample code assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. This sample code is provided for the purpose of illustration only and is not intended to be used in a production environment.

'Change Server and User name below
SERVER = "Server"
Mailbox = "User"
 
Set objSession = CreateObject("MAPI.Session")
objSession.LogOn , "", False, True, , True, SERVER  & Chr(10) & Mailbox
 
    Set objInfoStores = objSession.InfoStores
     For i = 1 To objInfoStores.Count
        If UCase(objInfoStores.Item(i)) = UCase("Public Folders") Then
            Set objInfoStore = objInfoStores.Item(i)
                msgbox objInfoStore.name 
            Exit For
        End If
    Next
 
Set objInfoStores= Nothing
Set objSession=Nothing
 
The above sample code would not return the name of the Public Folders store to us.
 
We need to work around the above issue by creating another session object as per the below code snippet:
 
'Change Server and User name below
SERVER = "Server"
Mailbox = "User"
 
Set objSession = CreateObject("MAPI.Session")
objSession.LogOn , "", False, True, , True, SERVER  & Chr(10) & Mailbox
 
    Set objInfoStores = objSession.InfoStores
     For i = 1 To objInfoStores.Count
        If UCase(objInfoStores.Item(i)) = UCase("Public Folders") Then
            Set objInfoStore = objInfoStores.Item(i)
                msgbox objInfoStore.name 
            Exit For
        End If
    Next
 
 
Set objSession2 = CreateObject("MAPI.Session")
objSession2.LogOn , "", False, False, , True, SERVER  & Chr(10) & Mailbox
 
    Set objInfoStores2 = objSession2.InfoStores
     For i = 1 To objInfoStores2.Count
        If UCase(objInfoStores2.Item(i)) = UCase("Public Folders") Then
            Set objInfoStore2 = objInfoStores2.Item(i)
                msgbox objInfoStore2.name 
            Exit For
        End If
    Next
 
Set objInfoStores= Nothing
Set objSession=Nothing
 
Set objInfoStores2= Nothing
Set objSession2=Nothing

 

Note: We are using third parameter as “False” for objSession2.Logon, So that it uses the current shared MAPI session.

How to do FindItem using Extended MAPI Properties in a Exchange Web Service call?

We can perform GetItem Exchange Web Service call to get Extended MAPI Properties refer my previous post How to get Extended MAPI Properties in the GetItem Exchange Web Service call? and can also perform FindItem based on the Extended MAPI Properties.

In the sample code given below we would use CleanGlobalObjectId to perform FindItem for Calendar Items:

NOTE: Following programming examples is for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This sample code assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures.

 

    private void SelectRecordByCGOID()
        {
            
            //prepare the find item request: we have to use FindItem because
            //this is the only way to search by CleanGlobalObjectID; GetItem does not allow us
            //to search with Restrictions
            FindItemType findItemRequest = new FindItemType();
            DistinguishedFolderIdType[] folderIDArray = new DistinguishedFolderIdType[1];
            folderIDArray[0] = new DistinguishedFolderIdType();
            folderIDArray[0].Id = DistinguishedFolderIdNameType.calendar;
            folderIDArray[0].Mailbox = new EmailAddressType();
            folderIDArray[0].Mailbox.EmailAddress = "brijs@msglab.com";
          
            // Add folders to the request.
            findItemRequest.ParentFolderIds = folderIDArray;
            findItemRequest.Traversal = ItemQueryTraversalType.Shallow;
 
            //Prepare an Item shape type that defines how the items in view will be returned.
            ItemResponseShapeType itemShapeDefinition = new ItemResponseShapeType();
            itemShapeDefinition.BaseShape = DefaultShapeNamesType.AllProperties  ;
 
            
            //filter the results by the CleanGlobalObjectID passed in
            PathToExtendedFieldType path = new PathToExtendedFieldType();
            
            path.PropertyId = 35;
            path.PropertyIdSpecified = true;
            path.PropertySetId = "6ED8DA90-450B-101B-98DA-00AA003F1305";
            path.PropertyType = MapiPropertyTypeType.Binary;
                 
 
            FieldURIOrConstantType constant = new FieldURIOrConstantType();
            ConstantValueType constantValue = new ConstantValueType();
            constantValue.Value = itemGCOID ;
            constant.Item = constantValue;
 
            RestrictionType restriction = new RestrictionType();
            IsEqualToType equal = new IsEqualToType();
            equal.Item = path;
            equal.FieldURIOrConstant = constant;
            restriction.Item = equal;
 
            //Add the itemShape definition and restriction to the FindItem request
            findItemRequest.ItemShape = itemShapeDefinition;
            findItemRequest.Restriction = restriction;
            
            FindItemResponseType findItemResponse = binding.FindItem(findItemRequest);
 
            for (int i = 0; i < findItemResponse.ResponseMessages.Items.Length; i++)
            {
                //verify the FindItem request was successfull
                if (findItemResponse.ResponseMessages.Items[i].ResponseClass != ResponseClassType.Success)
                {
                    throw new Exception(string.Format(
                        "Unable to find calendar view by CleanGlobalObjectID \r\n{0}\r\n{1}",
                        findItemResponse.ResponseMessages.Items[i].ResponseCode,
                        findItemResponse.ResponseMessages.Items[i].MessageText));
                }
                else
                {
                        //Success
                        //get the calendar items contained in the response
                        FindItemResponseMessageType findItemResponseMessage = (FindItemResponseMessageType)findItemResponse.ResponseMessages.Items[i];
                        ArrayOfRealItemsType findItemResponseItems = (ArrayOfRealItemsType)findItemResponseMessage.RootFolder.Item;
 
                        for (int x = 0; x < findItemResponseMessage.RootFolder.TotalItemsInView; x++)
                        {
                            if (findItemResponseItems.Items[x] is CalendarItemType)
                            {
                                CalendarItemType calendar = (CalendarItemType)findItemResponseItems.Items[x];
                                Console.WriteLine( "Item found ");
                                Console.WriteLine( calendar.Subject);
                            }
                        }
                 }
            }
                                    
        }

Hope this helps!

How to get Extended MAPI Properties in the GetItem Exchange Web Service call?

We can get/set Extended MAPI Properties using Exchange Web Services for Exchange Server 2007/2010.

Here is sample code snippet to get value for CleanGlobalObjectID via GetItem call of Exchange Web Services:

NOTE: Following programming examples is for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This sample code assumes that you are familiar with the programming language being demonstrated and the tools used
to create and debug procedures.

private void fnGetCalItem()
        {
            // Form the GetItem request
            GetItemType getRequest = new GetItemType();
 
            // Define which item properties are returned in the response
            ItemResponseShapeType itemProperties = new ItemResponseShapeType();
            itemProperties.BaseShape = DefaultShapeNamesType.AllProperties;
 
            // Add properties shape to request
            getRequest.ItemShape = itemProperties;
 
            // Set the itemID of the desired item to retrieve
            ItemIdType id = new ItemIdType();
            id.Id = itemID;
            getRequest.ItemIds = new ItemIdType[] { id };
 
 
            PathToExtendedFieldType[] pteft = new PathToExtendedFieldType[1];
 
            pteft[0] = new PathToExtendedFieldType();
            
            //Add CleanGlobalObjectID extended property 
            pteft[0].PropertyId = 35;
            pteft[0].PropertyIdSpecified = true;
            pteft[0].PropertySetId  = "6ED8DA90-450B-101B-98DA-00AA003F1305" ; 
            pteft[0].PropertyType = MapiPropertyTypeType.Binary;
            itemProperties.AdditionalProperties = pteft;
 
            // Send the listing (find) request and get the response
            GetItemResponseType getResp = binding.GetItem(getRequest);
 
            // Get the response message
            if (getResp.ResponseMessages.Items[0].ResponseClass == ResponseClassType.Success)
            {
                ItemInfoResponseMessageType iirmt = getResp.ResponseMessages.Items[0] as ItemInfoResponseMessageType;
                itemGCOID = iirmt.Items.Items[0].ExtendedProperty[0].Item.ToString() ;
             }
            else
            {
                Console.WriteLine(getResp.ResponseMessages.Items[0]);
            }
        }

 

Articles referenced for the above sample code:

Hope this helps!

How to deploy VSTO add-ins for Outlook?

“What is the best way to deploy VSTO add-ins for Outlook?” This is one of the most common question asked by our customers who are developing add-ins using Visual Studio Tools for Office(VSTO) for Outlook and other Office Applications.  Simple answer is that it’s all depend on you requirements and environment. We can opt for either ClickOnce Deployment or Windows Installer.

We can refer to Choosing a Deployment Strategy and the following table compares the features of ClickOnce deployment with Windows Installer deployment to make informed decision:

Features

ClickOnce

Windows Installer

Automatic update1

Yes

Yes

Post-installation rollback2

Yes

No

Update from Web

Yes

No

Does not affect shared components or other applications

Yes

No

Security permissions granted

Grants only permissions necessary for the application (more safe)

Grants Full Trust by default (less safe)

Security permissions required

Internet or Intranet Zone (Full Trust for CD-ROM installation)

Administrator

Application and deployment manifest signing

Yes

No

Installation-time user interface

Single prompt

Multipart Wizard

Installation of assemblies on demand

Yes

No

Installation of shared files

No

Yes

Installation of drivers

No

Yes (with custom actions)

Installation to Global Assembly Cache

No

Yes

Installation for multiple users

No

Yes

Add application to Start menu

Yes

Yes

Add application to Startup group

No

Yes

Add application to Favorites menu

No

Yes

Register file types

Yes

Yes

Install time registry access3

Limited

Yes

Binary file patching

No

Yes

Application installation location

ClickOnce application cache

Program Files folder

Articles to refer

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Notes:

1. With Windows Installer, you must implement programmatic updates in the application code.

2. With ClickOnce, rollback is available in Add or Remove Programs.

3. ClickOnce deployment can access HKEY_LOCAL_MACHINE (HKLM) only with Full Trust permission.

Feel free to put questions related to ClickOnce or Windows Installer deployment for Office Add-ins to me.

Exchange Web Services and Exchange 2010 - What’s new Webcasts

Exchange 2010 is on it way and along with it Exchange Web Services Managed API would be one-in-all interface for developing custom applications.

So, If you are developing Exchange related application and interested to know what you can do with the new EWS Managed API and what’s new in Exchange 2010 for developers then, Here are few interesting web casts to learn more: 

10/13/2009 - Exchange Server 2010 Development (Part 1 of 6): Migrating Applications to Exchange Web Services

10/14/2009 - Exchange Server 2010 Development (Part 2 of 6): A Deep Dive into Using Autodiscover Service in Exchange Web Services

10/15/2009 - Exchange Server 2010 Development (Part 3 of 6): A Deep Dive into Impersonation and Delegation in Exchange Web Services

10/20/2009 - Exchange Server 2010 Development (Part 4 of 6): A Deep Dive into Exchange Web Services Notifications (Push/Pull)

10/21/2009 - Exchange Server 2010 Development (Part 5 of 6): A Deep Dive into the Exchange Web Services Managed API

10/22/2009 - Exchange Server 2010 Development (Part 6 of 6): Best Practices for Building Scalable Exchange Server Applications

If you can’t wait for it, then have a sneak peek from quick video with Jason Henderson and David Claux of the EWS team @ Chris Mayo’s post.

Enjoy!!!

How to create a Service Account with full access to all mailboxes on Exchange Server 2007 mailboxstore?

We can use following Exchange PowerShell cmdlet to grant a Service Account full access to all the mailboxes on Exchange Server 2007 mailboxstore, but do so only in accordance with your organization's security and privacy policies:

Get-mailboxserver <servername> | add-adpermission –user <service account> -accessrights GenericRead, 
GenericWrite -extendedrights Send-As, Receive-As, ms-Exch-Store-Admin

We need to modify <servername> as the Exchange Server name and <service account> as the account for which we would like to grant access.

If you have further questions related to Exchange 2007 Permissions then please refer to
Exchange 2007 Permissions: Frequently Asked Questions

And if you writing a custom application using EWS or Exchange Web Services Managed API for Exchange 2007 then you can also have look at nice post @ Exchange Impersonation vs Delegate Access. which explain difference between Exchange Impersonation and  Delegate Access to access an Exchange mailbox using Exchange Web Services.

Exchange 2007 Webcasts for Client Access and Web Services

Want to learn more about Microsoft Exchange Server 2007 then Support WebCasts  are way to go. Support Webcasts are a free Internet broadcast service that is provided by Microsoft. You can view webcasts on-demand, and you can also download them in Microsoft Windows Media format for offline viewing.

Here are few worthy of note webcasts which I found for the Exchange developers:

Join us for a look at the various underlying components of Exchange Server 2007 Client Access Services. We cover the enhanced calendar functionality, the new Unified Messaging and Exchange Server Web services, and programmatic access to messaging data. We conclude the session by examining Exchange Server ActiveSync improvements.

TechNet Webcast : Exchange Server 2007 Client Access and Web Services (Level 200)

Learn about the Exchange 2007 implementation of the Autodiscover service. You can use this service to automatically configure Microsoft Office Outlook 2007 with connection settings so that it can easily connect to the Exchange 2007 server. The Support WebCast includes information about server and certificate configuration in various environments to achieve optimal functionality. Discover more yourself, and watch Support WebCast : Introduction to Autodiscover in Microsoft Exchange Server 2007.

Support WebCast : Introduction to Autodiscover in Microsoft Exchange Server 2007.

If you want to explore more, and get you on your way quickly, here are some webcasts that you might be interested in:

Happy Learning…

How to search for SMTP Servers in a domain programmatically using ADSI?

Here is a sample vbscript using which we can get SMTP servers instance names in a particular domain pragmatically via ADSI.

NOTE: Following programming examples is for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This sample code assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. This sample code is provided for the purpose of illustration only and is not intended to be used in a production environment.

Option Explicit
Dim conn
Dim com
Dim iAdRootDSE
Dim strNC
Dim strQry
Dim RS
Dim strstmsrv
Dim svsSmtpserver
Dim crServerName
 
set conn = createobject("ADODB.Connection")
set com = createobject("ADODB.Command")
Set iAdRootDSE = GetObject("LDAP://RootDSE")
 
strNC = iAdRootDSE.Get("configurationNamingContext")
 
conn.Provider = "ADsDSOObject"
conn.Open "ADs Provider"
com.ActiveConnection = Conn
com.ActiveConnection = Conn
 
Wscript.echo
Wscript.echo "SMTP Virtual Servers"
 
'Get SMTP server query using protocolCfgSMTPServer object class
strQry = "<LDAP://" & strNC & ">;(objectCategory=protocolCfgSMTPServer);name,distinguishedName;subtree"
 
com.ActiveConnection = conn
com.CommandText = strQry
 
Set RS = com.Execute
 
While Not RS.EOF
    strstmsrv = "LDAP://" & rs.fields("distinguishedName")
    set svsSmtpserver = getobject(strstmsrv)
    crServerName = mid(svsSmtpserver.distinguishedName,instr(svsSmtpserver.distinguishedName,"CN=Protocols,")+16,instr(svsSmtpserver.distinguishedName,",CN=Servers")-(instr(svsSmtpserver.distinguishedName,"CN=Protocols,")+16))
    wscript.echo
    wscript.echo "ServerName:" & crServerName
    
    RS.movenext
wend
 
Set RS=Nothing
Set com=Nothing
Set conn=Nothing

 

Here is another good example of where protocolCfgSMTPServer object class is used to find SMTP Virtual Server and set Message Restriction on an SMTP Virtual Server Using ADSI in VB @ Setting Message Restriction on an SMTP Virtual Server Using ADSI.

Hope this helps.

Download Available for Exchange Server 2007 Service Pack 2

You can now download Exchange Server 2007 Service Pack 2 from here Exchange Server 2007 SP2

We can refer to the following links to know more about SP2 in details:

Things which would be of interest for Exchange application developers are: 

  • Named Properties cmdlets - SP2 enables Exchange administrators to monitor their named property usage per database.
  • New User Interface for Managing Diagnostic Logging- SP2 enables Exchange administrators to easily configure and manage diagnostic logging from within the Exchange Management Console.

    Exchange Server 2007 Service Pack 2 (SP2), the Manage Diagnostic Logging Properties wizard is added to the Exchange Management Console. In Exchange Server 2007 Service Pack 1 or an earlier version, you must use the Exchange Management Shell to change diagnostic logging levels. for further reading Diagnostic Logging of Exchange Processes

  • Unable to open Outlook item attached using Attachments.Add and using the olByReference flag on the Outlook 2007

    One of our customer is sending Outlook item attached using Attachments.Add with olByReference Flag on Outlook 2007. If the recipient of the email tries to open the attached item

    will get “Microsoft Office Oulook could not complete the operation. One or more parameters values are not valid” exception.

    OlAttachErr

    To repro the issue we can use following sample VBA code snippet:

    NOTE: Following programming examples is for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This sample code assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. This sample code is provided for the purpose of illustration only and is not intended to be used in a production environment.

    Sub SendCurrentItemAsAttach()
        Set currItem = Application.ActiveInspector.CurrentItem
        currItem.Save
        Set RequestItem = Application.CreateItem(0)
        RequestItem.Subject = "Please check attached mail"
        RequestItem.HTMLBody = "Please check attached mail" & Chr(13) 
        RequestItem.To = "test@domain.com" 
        Set myAttachments = RequestItem.Attachments
        myAttachments.Add currItem, 4 'olByReference(4)
        RequestItem.Send
        Set RequestItem = Nothing
    End Sub

    The above issue is happening because of the design changes in the Outlook 2007.

    One workaround to address the above issue is to include a hyperlink in the email using the Outlook:\\<ENTRYID> protocol to link to the existing item rather than attaching the item ByRef. So to avoid above issue we can use following VBA sample code snippet:

    Sub SendCurrentItemAsAttach()
        Set currItem = Application.ActiveInspector.CurrentItem
        currItem.Save
        Set RequestItem = Application.CreateItem(0)
        RequestItem.Subject = "Please check attached mail"
        RequestItem.HTMLBody = "Please click to open the requestl" & Chr(13) & "<a href=Outlook:\\" & currItem.EntryID & ">Click Mail</a>"
        RequestItem.To = "test@domain.com"
        RequestItem.Send
        Set RequestItem = Nothing
    End Sub

    IMP: using Outlook:EntryID approach but it would works ONLY in case of HTML/RTF mail.

    References:

    FYI: Outlook 2003 and Exchange Server 2003 goes into Extended Support

    Outlook 2003 and Exchange Server 2003 goes into extended Support from 4/14/2009

    What is the difference between Mainstream Support, Extended Support, and online self-help support?

    Support provided

    Mainstream Support phase

    Extended Support phase

    Paid support (per-incident, per hour, and others)

    X

    X

    Security update support

    X

    X

    Non-security hotfix support

    X

    Requires extended hotfix agreement, purchased within 90 days of mainstream support ending.

    No-charge incident support

    X

       NA

    Warranty claims

    X

    NA

    Design changes and feature requests

    X

    NA

    Product-specific information that is available by using the online Microsoft Knowledge Base

    X

    X

    Product-specific information that is available by using the Support site at Microsoft Help and Support to find answers to technical questions

    X

    X

    IMP: Microsoft will NOT accept requests for warranty support, design changes, or new features during the Extended Support phase.

    To understand Support Lifecycle policy we can refer to Microsoft Support Lifecycle Policy FAQ

    To find the support timelines for other Microsoft products, visit the Select a Product for Lifecycle Information site (products listed by Product Family) or the Support Lifecycle Index site.

    Remove all PST from the Outlook Mailbox using VBScript

    If you would like to remove all of the Personal Folders file .PSTs attached to the Outlook Mailbox profile then we can use RemoveStore Method.

    Here is a sample VBScript to perform the job for us:

    NOTE: Following programming examples is for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This sample code assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. This sample code is provided for the purpose of illustration only and is not intended to be used in a production environment.

    'Sample script to remove Personal Folders files (.pst) from the current MAPI profile or session
    RemoveAllPST
     
    Sub RemoveAllPST()
    Dim objOL 'As New Outlook.Application
    Dim objFolders 'As Outlook.MAPIFolders
    Dim objFolder 'As Outlook.MAPIFolder
    Dim i 'As Interger
    Dim strPrompt 'As String
     
    Set objOL = CreateObject("Outlook.Application")
    Set objFolders = objOL.Session.Folders
    For i = objFolders.Count To 1 Step -1
    On Error Resume Next
        Set objFolder = objFolders.Item(i)
         
        'Prompt the user for confirmation
        If (InStr(1, objFolder.Name, "Mailbox") = 0) And (InStr(1, objFolder.Name, "Public Folders") = 0) Then
        
        strPrompt = ""
        strPrompt = "Are you sure you want to remove " & objFolder.Name
       
        If MsgBox(strPrompt, vbYesNo + vbQuestion) = vbYes Then
            objOL.Session.RemoveStore objFolder
        End If
        End If
    Next
     
    End Sub

    We can also refer to the article mentioned below related to RemoveStore Method:

    NameSpace.RemoveStore Method
    http://msdn.microsoft.com/en-us/library/bb219923.aspx

    Hope this helps.

    More Posts Next page »
     
    Page view tracker