Results 1 to 11 of 11

Thread: Contact In Outlook

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2002
    Location
    Connecticut, USA
    Posts
    308

    Contact In Outlook

    Can I, using VB, add names and other related information, to my Contacts List in Outlook?

  2. #2
    Junior Member rjhare's Avatar
    Join Date
    Sep 2001
    Location
    Peterborough, UK
    Posts
    31
    If you do find an answer to this, I would appreciate a copy please. This is one of the few areas of the Outlook OM that I cant seem to get my head around. Good luck. Richard

    [email protected]

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    Try this y'all...
    VB Code:
    1. Private o1 As Outlook.Application
    2.  
    3. Private Function CreateContact(Name As String, Nick As String, Email As String, Optional Folder As Outlook.MAPIFolder = Nothing) As Outlook.ContactItem
    4.    'Create a new contact item
    5.     If Folder Is Nothing Then
    6.         Set CreateContact = o1.CreateItem(olContactItem)
    7.     Else
    8.         Set CreateContact = Folder.Items.Add(olContactItem)
    9.     End If
    10.     'Set a few of the many possible contact parameters.
    11.     CreateContact.FullName = "Name"
    12.     CreateContact.NickName = "NickName"
    13.     CreateContact.Email1Address = "Email"
    14.     'Commit the contact
    15.     CreateContact.Save
    16. End Function

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    Ask and ye shall receive (but next time, please don't PM me. Post your request on the forum. Thanks. )
    VB Code:
    1. Private Sub CreateAppointment(StartTime As Date, Endtime As Date, Subject As String, Location As String)
    2.     'Create a reference to a Appointment item
    3.     Dim e1 As Outlook.AppointmentItem
    4.     'Create a new appointment item
    5.     Set e1 = o1.CreateItem(olAppointmentItem)
    6.     'Set a few of the many possible appointment parameters.
    7.     e1.Start = StartTime
    8.     e1.End = Endtime
    9.     e1.Subject = Subject
    10.     e1.Location = Location
    11.     'If you want to set a list of recipients, do it like this
    12.     'e1.Recipients.Add Name
    13.     'Commit the appointment
    14.     e1.Send
    15.     'Free up the space
    16.     Set e1 = Nothing
    17. End Sub

  5. #5
    New Member
    Join Date
    Sep 2002
    Location
    Tasmania
    Posts
    4
    Does anyone know a way of doing this without using the Outlook Object?
    Stephen

  6. #6
    Frenzied Member
    Join Date
    Jan 2001
    Location
    Newbury, UK
    Posts
    1,878
    My way of thinking says that is not a sensible question.

    If you want to add Contacts to Outlook you need to use the Outlook objects.

    But my way of thinking might not be correct! So, please explain more .

  7. #7
    New Member
    Join Date
    Sep 2002
    Location
    Tasmania
    Posts
    4
    I can access and modify objects using only ADO. THe only hitch is that I haven't been able to add a new record. Seems to be a permissions problem.
    Yes it is easy with the Outlook object but due to constraints I have to come up with a solution that doesn't use them.
    Stephen

  8. #8
    Frenzied Member
    Join Date
    Jan 2001
    Location
    Newbury, UK
    Posts
    1,878
    I doubt if its permissions.... I would have thought that Outlook (and Exchange?) would have prevented you from seeing the records as well if permission was denied.

    Maybe ADO needs a different function in order to set / modify values?

    Try posting your code that allows access, and we can see if its permissions or something different.

  9. #9
    Hyperactive Member
    Join Date
    Feb 2000
    Location
    Edgerton, WI
    Posts
    381
    Hack,

    Do you have any sample code that would allow me to import addresses from a table or query in an Access 2000 DB to Outlook. I would need to map the fields since the field names in Access db are not the same as those in Outlook. Any help with sample code as above would be greatly appreciated.

    Also, it would be nice, but not neccessary, would there be a way to sync the two so that an address changed in one would be reflected in the other.

    Thanks,
    Rev. Michael L. Burns

  10. #10
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    No, I don't, but theoretically this should work with a Access2000 table. This is a revised piece of the code I posted earlier in this thread. This examples presumes you have a valid connection with your Access DB, and have created a recordset with this SQL
    Code:
    SQL = "SELECT firstname, nickname, lastname, EMailAddr FROM addresstable "
    VB Code:
    1. 'Now, with that recordset having been made, this should work
    2. Private o1 As Outlook.Application
    3.  
    4.    Dim FullName As String
    5.    'Create a new contact item
    6.    Do While Not Rs.EOF
    7.     FullName = Rs(0) & " " & Rs(2)
    8.     CreateContact.FullName = FullName
    9.     CreateContact.NickName = Rs(1)
    10.     CreateContact.Email1Address = Rs(3)
    11.     'Commit the contact
    12.     CreateContact.Save
    13.     Rs.MoveNext
    14. Loop
    15. End Function
    Hope this helps (Disclaimer: this is an untested example )

  11. #11
    Hyperactive Member
    Join Date
    Feb 2000
    Location
    Edgerton, WI
    Posts
    381
    Thanks Hack. I'll give this a try when I get a chance.

    Pastor Mike

Posting Permissions

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



Click Here to Expand Forum to Full Width