Solved

Batch Updating of Custom Fields

Posted on 2000-04-04
3
302 Views
Last Modified: 2010-04-08
I have created several custom fields such as initial mail date, second mail date, etc., which I would like to be able to update on a batch basis. For instance, when we do a mail campaign, I would like to be able to select 1000 names and update the inital mail date field with the date of the mailing. Is there a simple way to do this?
0
Comment
Question by:altschuler
  • 2
3 Comments
 
LVL 2

Accepted Solution

by:
brice123 earned 50 total points
ID: 2686403
Updating mail items in batch mode can be done very simply with a small Visual Basic program (or a VBA procedure if you are running Outlook 2000).

For example, I've created a new post form (based on the standard mail item) called IPM.Post.CustomMail.

In this form, I have added a custom field called usrScore (Number).

Then, I have published the new form in my Personal Forms Library.

For my test code, I've sent some mails by using my new form (New -> Choose form -> Personal Forms Library -> Custom Mail).

OK, let's go for the VB part now:

Create a new project, remove the default form and add a new module.
Paste the following code :

Option Explicit

Public Sub main()
  MsgBox GetSumFromOutlook, vbOKOnly, "Sum of Score Field"
End Sub

Public Function GetSumFromOutlook() As Long
  Dim olApp As Outlook.Application
  Dim olNameSpace As Outlook.NameSpace
  Dim olFolder As Outlook.MAPIFolder
  Dim olItem As Object
  Dim lngSum As Long
 
  ' Create a new instance of the Outlook application object
  Set olApp = New Outlook.Application
 
  ' Get the default MAPI namespace
  Set olNameSpace = olApp.GetNamespace("MAPI")
 
  ' Get the default Inbox folder
  Set olFolder = olNameSpace.GetDefaultFolder(olFolderInbox)
 
  ' Loop through mail items
  For Each olItem In olFolder.Items
      ' Compute the sum of usrScore
      If olItem.FormDescription = "CustomMail" Then
        lngSum = lngSum + olItem.UserProperties("usrScore")
       
        ' Reset the score
        olItem.UserProperties("usrScore") = 0
        ' Update the item
        olItem.Save
       
      End If
  Next

  ' Destroy references
  Set olItem = Nothing
  Set olFolder = Nothing
  Set olNameSpace = Nothing
  Set olApp = Nothing

  ' Return the result
  GetSumFromOutlook = lngSum
End Function

Press F5 to run the project.

The function GetSumFromOutlook will compute the sum of all usrScore fields and replace the current value.

Drop me a line if you want further explanations.
0
 

Author Comment

by:altschuler
ID: 2686966
brice123 - Thank you very much for your response. I tried to contact you to follow-up but was not able to get direct contact information from your profile.

I am actually trying to update a custom contact form. The contact form has the name of the company, contact person, and initial mail date, second mail date, etc. Can the code that you suggested be modified for this purpose? Alternatively, is there a different method to update these fields? (btw, I am using outlook 2000) Thanks agian for your assistance.
0
 

Author Comment

by:altschuler
ID: 2690674
brice123 - Thank you very much for your response. I tried to contact you to follow-up but was not able to get direct contact information from your profile.

I was able to accomplish the task with the following code.

Sub UpdateDateFields2()
 Dim objContactsFolder As Outlook.MAPIFolder
   Dim objContacts As Outlook.Items
   Dim strDateSelect As String
   Dim strDate As Date
   Dim objContact As Object
   Dim iCount As Integer

   ' Specify which contact folder to work with
   Set objContactsFolder = Outlook.ActiveExplorer.CurrentFolder
   Set objContacts = objContactsFolder.Items

   ' Prompt for field and date
   strDateSelect = InputBox("Enter the field to update.")
   strDate = InputBox("Enter date.")
 

   iCount = 0

   ' Process the changes
   For Each objContact In objContacts
      If TypeName(objContact) = "ContactItem" Then
        objContact.UserProperties.Find(strDateSelect) = strDate
        objContact.Save
        iCount = iCount + 1
      End If
   Next
   
   MsgBox "Number of contacts updated:" & Str$(iCount)

   ' Clean up
   Set objContact = Nothing
   Set objContacts = Nothing
   Set objContactsFolder = Nothing
End Sub


Thanks again for your assistance.
0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Outlook 365 crashing. 4 44
Outlook 2013 hangs on Synchronization 4 29
Exchange Server 2016 certifiate error 13 50
How to get windows DNS resolve to internal address? 3 39
Find out what you should include to make the best professional email signature for your organization.
Large Outlook files lead to various unwanted errors and corruption issues. Furthermore, large outlook files can also make Outlook take longer to start-up, search, navigate, and shut-down. So, In this article, i will discuss a method to make your Out…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …

832 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question