Results 1 to 2 of 2
  1. #1
    3 Star Lounger
    Join Date
    Feb 2001
    Location
    Portland, Maine, USA
    Posts
    296
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Outlook Custom Form (Outlook 2000, SR1)

    I have a custom email form for phone messages. This has fields for "Contact" and "Phone Number". I want to be able grab the information from this message form to create a new contact. What is the code to grab the custom field data?

  2. #2
    3 Star Lounger
    Join Date
    Feb 2001
    Location
    Portland, Maine, USA
    Posts
    296
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Outlook Custom Form (Outlook 2000, SR1)

    I still need to do some testing for conditions that may cause this to fail, but this code works to copy data from the fields in a custom phone message form to create a new contact. Most of this came right out of Sue Mosher's book "Outlook 2000 Programming in 24 Hours."

    The code looks at whatever item is selected in Outlook. If the form has the correct custom fields, the code will run through. If it can not find one of the referenced fields, the on error condition displays a message telling the user they must have a phone message form selected.


    Sub Copyto()

    Dim objApp As Application
    Dim objItem As Object
    Dim objContact As ContactItem
    Dim strTester As String
    Dim strMsg As String
    Dim response

    strMsg = "You must have a 'phone message' selected" & _
    vbCrLf & vbCrLf & _
    "in the Outlook Window to use this program"
    Set objApp = CreateObject("Outlook.Application")
    Set objItem = objApp.ActiveExplorer.Selection.Item(1)
    Set objContact = objApp.CreateItem(olContactItem)

    On Error GoTo WrongForm

    objContact.FullName = objItem.UserProperties("Please Contact")
    objContact.BusinessTelephoneNumber = objItem.UserProperties("PhoneNumber")
    objContact.Email1Address = objItem.UserProperties("Email")
    objContact.Body = objItem.Body
    objContact.Display
    Exit Sub


    WrongForm:
    response = MsgBox(strMsg, vbInformation, "Add Contact")

    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •