Solved

Batch Updating of Custom Fields

Posted on 2000-04-04
3
328 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

What does UTC stand for?  “Coordinated Universal Time” – Think of this as the true time on Planet Earth that never changes with the exception of minor leap seconds here and there to account for the changes in the planet's rotation.   What does th…
This article lists the top 5 free OST to PST Converter Tools. These tools save a lot of time for users when they want to convert OST to PST after their exchange server is no longer available or some other critical issue with exchange server or impor…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

688 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