|
-
Jun 24th, 2002, 08:33 AM
#1
Thread Starter
Hyperactive Member
Contact In Outlook
Can I, using VB, add names and other related information, to my Contacts List in Outlook?
-
Jun 24th, 2002, 09:00 AM
#2
Junior Member
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]
-
Jun 24th, 2002, 11:15 AM
#3
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
-
Jun 24th, 2002, 11:38 AM
#4
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
-
Sep 30th, 2002, 08:32 PM
#5
New Member
Does anyone know a way of doing this without using the Outlook Object?
-
Oct 1st, 2002, 03:55 AM
#6
Frenzied Member
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 .
-
Oct 1st, 2002, 06:01 PM
#7
New Member
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.
-
Oct 2nd, 2002, 02:56 AM
#8
Frenzied Member
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.
-
Oct 3rd, 2002, 11:33 AM
#9
Hyperactive Member
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
-
Oct 3rd, 2002, 12:19 PM
#10
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:
'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
Hope this helps (Disclaimer: this is an untested example )
-
Oct 3rd, 2002, 08:46 PM
#11
Hyperactive Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|