Can I, using VB, add names and other related information, to my Contacts List in Outlook?
Printable View
Can I, using VB, add names and other related information, to my Contacts List in Outlook?
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] :)
Try this y'all...VB Code:
Private o1 As Outlook.Application Private Function CreateContact(Name As String, Nick As String, Email As String, Optional Folder As Outlook.MAPIFolder = Nothing) As Outlook.ContactItem 'Create a new contact item If Folder Is Nothing Then Set CreateContact = o1.CreateItem(olContactItem) Else Set CreateContact = Folder.Items.Add(olContactItem) End If 'Set a few of the many possible contact parameters. CreateContact.FullName = "Name" CreateContact.NickName = "NickName" CreateContact.Email1Address = "Email" 'Commit the contact CreateContact.Save End Function
Ask and ye shall receive (but next time, please don't PM me. Post your request on the forum. Thanks. :) )VB Code:
Private Sub CreateAppointment(StartTime As Date, Endtime As Date, Subject As String, Location As String) 'Create a reference to a Appointment item Dim e1 As Outlook.AppointmentItem 'Create a new appointment item Set e1 = o1.CreateItem(olAppointmentItem) 'Set a few of the many possible appointment parameters. e1.Start = StartTime e1.End = Endtime e1.Subject = Subject e1.Location = Location 'If you want to set a list of recipients, do it like this 'e1.Recipients.Add Name 'Commit the appointment e1.Send 'Free up the space Set e1 = Nothing End Sub
Does anyone know a way of doing this without using the Outlook Object?
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 .
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.
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.
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
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 SQLCode:SQL = "SELECT firstname, nickname, lastname, EMailAddr FROM addresstable "
Hope this helps (Disclaimer: this is an untested example :) )VB Code:
'Now, with that recordset having been made, this should work Private o1 As Outlook.Application Dim FullName As String 'Create a new contact item Do While Not Rs.EOF FullName = Rs(0) & " " & Rs(2) CreateContact.FullName = FullName CreateContact.NickName = Rs(1) CreateContact.Email1Address = Rs(3) 'Commit the contact CreateContact.Save Rs.MoveNext Loop End Function
Thanks Hack. I'll give this a try when I get a chance.
Pastor Mike