File Object

Outlook Developer Reference
File Object

The File object represents a record of the files linked to a new or existing account, business contact, or opportunity.

Version Information
 Version Added:  Outlook 2007

Requirements

Business Contact Manager for Outlook

Remarks

When you link a file to an account, contact, or opportunity record, the file appears in the Communication History section of the record. You can include text files, such as, contract or letters to customers, Excel sheets providing supporting data, and graphic materials.

To create a business note programmatically, do the following:

  1. Instantiate an Outlook.JournalItem object, where the journal item is of type File.
  2. Assign properties to the file.
  3. Set the Parent Entity EntryID property of the journal item to the entry ID of a new or existing account, business contact, or opportunity.

You must associate a File object with an Account, Business Contact, Opportunity, or Business Project object. The Communication History folder contains file items.

Example

The following C# and Visual Basic for Applications (VBA) examples show how to create a new object instance of type File.

C#
  
           Outlook.JournalItem journalItem = (Outlook.JournalItem)historyFolder.Items.Add("IPM.Activity.BCM");
          if (journalItem.UserProperties["Parent Entity EntryID"] == null)
        {
            userProp = journalItem.UserProperties.Add("Parent Entity EntryID", Microsoft.Office.Interop.Outlook.OlUserPropertyType.olText, false, false);
            userProp.Value = accountEntryID;
        }

        journalItem.Subject = "ExisitngFile.txt";
        journalItem.Type = "File";

        if (journalItem.UserProperties["LinkToOriginal"] == null)
        {
            userProp = journalItem.UserProperties.Add("LinkToOriginal", Microsoft.Office.Interop.Outlook.OlUserPropertyType.olText, false, false);
            userProp.Value = @"c:\ExisitngFile.txt";
        }

        journalItem.Save();</code>
Visual Basic for Applications
  
   Set objFile = bcmHistoryFolder.Items.Add("IPM.Activity.BCM")
   
   If (objFile.UserProperties("Parent Entity EntryID") Is Nothing) Then
        Set userProp = objFile.UserProperties.Add("Parent Entity EntryID", olText, False, False)
        userProp.Value = newAcct.EntryID
   End If
   
   objFile.Subject = "test.txt"
   objFile.Type = "File"
   
   If (objFile.UserProperties("LinkToOriginal") Is Nothing) Then
        Set userProp = objFile.UserProperties.Add("LinkToOriginal", olText, False, False)
        userProp.Value = "c:\test.txt"
   End If
   
   objFile.Save

User Properties (Business Contact Manager only)

None. All properties derive from the parent object.

Parent Objects

JournalItem Object

For more information, see the Outlook 2007 Developer Reference by going to the MSDN Office Developer Center Web site.

See Also

Appointments | Business Notes | E-Mail Messages | Phone Logs | Tasks