Important alert: (current site time 9/21/2014 11:52:02 PM EDT)
 

VB icon

GET OUTLOOK CALENDAR CONTACTS

Email
Submitted on: 3/4/2013 3:41:09 PM
By: Kevin Ritch  
Level: Advanced
User Rating: Unrated
Compatibility: VB 4.0 (32-bit), VB 5.0, VB 6.0
Views: 2752
author picture
(About the author)
 
     This is a simple way to search the calendar for appointments and pick off the linked contacts. (You would benefit from redemption to avoid the Outlook Security Msg, but it works just the same) JUST ADD A BUTTON AND A LIST BOX
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.
				
'**************************************
' Name: GET OUTLOOK CALENDAR CONTACTS
' Description:This is a simple way to search the calendar for appointments and pick off the linked contacts. (You would benefit from redemption to avoid the Outlook Security Msg, but it works just the same)
JUST ADD A BUTTON AND A LIST BOX
' By: Kevin Ritch
'
'This code is copyrighted and has' limited warranties.Please see http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=74713&lngWId=1'for details.'**************************************

Private Sub Command1_Click()
'=========================
'DIMENSION OUTLOOK OBJECTS
'=========================
 Dim objApp As Outlook.Application
 Dim objContact As ContactItem
 Dim colLinks As Links
 Dim objLink As Link
 Dim c As Outlook.AppointmentItem
 Dim objItems As Outlook.Items
'==================
'DEFINE THE OBJECTS
'==================
 Set objApp = New Outlook.Application
 Set objNS = objApp.GetNamespace("MAPI")
 Set objFolder = objNS.GetDefaultFolder(olFolderCalendar)
 Set objItems = objFolder.Items
'=======================================
'SEE HOW MANY CALENDAR ENTRIES THERE ARE
'=======================================
 CalendarEntries = objItems.Count
 For i = 1 To CalendarEntries
 '=========================
 'ONLY PROCESS APPOINTMENTS
 '=========================
 If TypeName(objItems(i)) = "AppointmentItem" Then
Set c = objItems(i)
Set colLinks = c.Links
 '=============================
 'ONLY WHERE THERE ARE CONTACTS
 '=============================
NumContacts = c.Links.Count
For n = 1 To NumContacts
Set objLink = colLinks(n)
Set objContact = objLink.Item
EMail$ = objContact.Email1Address
'=====================================================================
'ONLY IF THEY HAVE AN EMAIL ADDRESS TO MATCH TO IN THE CONTACT MANAGER
'=====================================================================
If InStr(EMail$, "@") Then
 List1.AddItem EMail$
End If
Next n
 End If
 Next i
'===============
'RELEASE OBJECTS
'===============
 Set c = Nothing
 Set objLink = Nothing
 Set colLinks = Nothing
 Set objFolder = Nothing
 Set objApp = Nothing
End Sub


Other 32 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Advanced category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.