Problems with Outlook.Recipient.Resolve

J

JoD

I am using Microsoft Office 2007 to create Outlook calendar appointments from
Access. I can successfully do this with one exception: I have a series of
calendars with similar names - the last portion of the name, for the 16
calendars, ranges from SEMI-1 to SEMI-16. With the code below, the .Resolve
method is unsuccessful for only the calendar ...SEMI-1.

I have verified that the name correctly matches the name of the calendar.
Any suggestions would be appreciated (including renaming that calendar, if
necessary!)

Dim objOutlook As Outlook.Application
Dim objNameSpace As Outlook.NameSpace
Dim objRecipient As Outlook.Recipient
Dim objFolder As Outlook.MAPIFolder
Dim objItems As Outlook.Items
Dim objAppt As Outlook.AppointmentItem
Dim myCalendar, strStart, strShortTime As String

'find and delete the corresponding calendar appointment
Set objOutlook = CreateObject("Outlook.Application")
Set objNameSpace = objOutlook.GetNamespace("MAPI")
If Len(Trim(Nz(Me!cboCalendar.Column(0)))) > 0 Then ' proceed, should be
an appointment

myCalendar = strCalendar
Set objRecipient = objNameSpace.CreateRecipient(myCalendar)
' check calendar name
objRecipient.Resolve
If objRecipient.Resolved Then
' create start date/time
strStart = strExamDate & " " & strStartTime
strStart = Format(strExamDate & " " & strStartTime, "mm/dd/yyyy
hh:mm AMPM")

' set values for objects and delete appointment
Set objFolder =
objNameSpace.GetSharedDefaultFolder(objRecipient, olFolderCalendar)
Set objItems = objFolder.Items
Set objAppt = objItems.Find("[Start] = """ & strStart & """")
If objAppt Is Nothing Then
MsgBox ("This appointment was not found in Outlook")
Else
objAppt.Delete
Set objAppt = Nothing
'Now display appropriate message
MsgBox ("Appointment deleted from Outlook")
End If

Set objItems = Nothing
Set objFolder = Nothing
Else
MsgBox ("No appointment deleted, could not resolve calendar name")
End If
Else
MsgBox ("No appointment deleted, no existing appointment")
End If

'Release the object variables
Set objNameSpace = Nothing
Set objRecipient = Nothing
Set objOutlook = Nothing
 
S

Sue Mosher [MVP]

Try prefixing each one with "=" to force Outlook to perform an exact match
on the name when it tries to resolve.
 
J

JoD

Could you kindly show me an example of what you mean? I'm not sure where the
"=" would go.

Thanks!

Sue Mosher said:
Try prefixing each one with "=" to force Outlook to perform an exact match
on the name when it tries to resolve.

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


JoD said:
I am using Microsoft Office 2007 to create Outlook calendar appointments
from
Access. I can successfully do this with one exception: I have a series of
calendars with similar names - the last portion of the name, for the 16
calendars, ranges from SEMI-1 to SEMI-16. With the code below, the
.Resolve
method is unsuccessful for only the calendar ...SEMI-1.

I have verified that the name correctly matches the name of the calendar.
Any suggestions would be appreciated (including renaming that calendar, if
necessary!)

Dim objOutlook As Outlook.Application
Dim objNameSpace As Outlook.NameSpace
Dim objRecipient As Outlook.Recipient
Dim objFolder As Outlook.MAPIFolder
Dim objItems As Outlook.Items
Dim objAppt As Outlook.AppointmentItem
Dim myCalendar, strStart, strShortTime As String

'find and delete the corresponding calendar appointment
Set objOutlook = CreateObject("Outlook.Application")
Set objNameSpace = objOutlook.GetNamespace("MAPI")
If Len(Trim(Nz(Me!cboCalendar.Column(0)))) > 0 Then ' proceed, should
be
an appointment

myCalendar = strCalendar
Set objRecipient = objNameSpace.CreateRecipient(myCalendar)
' check calendar name
objRecipient.Resolve
If objRecipient.Resolved Then
' create start date/time
strStart = strExamDate & " " & strStartTime
strStart = Format(strExamDate & " " & strStartTime, "mm/dd/yyyy
hh:mm AMPM")

' set values for objects and delete appointment
Set objFolder =
objNameSpace.GetSharedDefaultFolder(objRecipient, olFolderCalendar)
Set objItems = objFolder.Items
Set objAppt = objItems.Find("[Start] = """ & strStart & """")
If objAppt Is Nothing Then
MsgBox ("This appointment was not found in Outlook")
Else
objAppt.Delete
Set objAppt = Nothing
'Now display appropriate message
MsgBox ("Appointment deleted from Outlook")
End If

Set objItems = Nothing
Set objFolder = Nothing
Else
MsgBox ("No appointment deleted, could not resolve calendar
name")
End If
Else
MsgBox ("No appointment deleted, no existing appointment")
End If

'Release the object variables
Set objNameSpace = Nothing
Set objRecipient = Nothing
Set objOutlook = Nothing
 
S

Sue Mosher [MVP]

Set objRecipient = objNameSpace.CreateRecipient("=" & myCalendar)

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


JoD said:
Could you kindly show me an example of what you mean? I'm not sure where
the
"=" would go.

Thanks!

Sue Mosher said:
Try prefixing each one with "=" to force Outlook to perform an exact
match
on the name when it tries to resolve.

JoD said:
I am using Microsoft Office 2007 to create Outlook calendar appointments
from
Access. I can successfully do this with one exception: I have a series
of
calendars with similar names - the last portion of the name, for the 16
calendars, ranges from SEMI-1 to SEMI-16. With the code below, the
.Resolve
method is unsuccessful for only the calendar ...SEMI-1.

I have verified that the name correctly matches the name of the
calendar.
Any suggestions would be appreciated (including renaming that calendar,
if
necessary!)

Dim objOutlook As Outlook.Application
Dim objNameSpace As Outlook.NameSpace
Dim objRecipient As Outlook.Recipient
Dim objFolder As Outlook.MAPIFolder
Dim objItems As Outlook.Items
Dim objAppt As Outlook.AppointmentItem
Dim myCalendar, strStart, strShortTime As String

'find and delete the corresponding calendar appointment
Set objOutlook = CreateObject("Outlook.Application")
Set objNameSpace = objOutlook.GetNamespace("MAPI")
If Len(Trim(Nz(Me!cboCalendar.Column(0)))) > 0 Then ' proceed,
should
be
an appointment

myCalendar = strCalendar
Set objRecipient = objNameSpace.CreateRecipient(myCalendar)
' check calendar name
objRecipient.Resolve
If objRecipient.Resolved Then
' create start date/time
strStart = strExamDate & " " & strStartTime
strStart = Format(strExamDate & " " & strStartTime,
"mm/dd/yyyy
hh:mm AMPM")

' set values for objects and delete appointment
Set objFolder =
objNameSpace.GetSharedDefaultFolder(objRecipient, olFolderCalendar)
Set objItems = objFolder.Items
Set objAppt = objItems.Find("[Start] = """ & strStart &
"""")
If objAppt Is Nothing Then
MsgBox ("This appointment was not found in Outlook")
Else
objAppt.Delete
Set objAppt = Nothing
'Now display appropriate message
MsgBox ("Appointment deleted from Outlook")
End If

Set objItems = Nothing
Set objFolder = Nothing
Else
MsgBox ("No appointment deleted, could not resolve calendar
name")
End If
Else
MsgBox ("No appointment deleted, no existing appointment")
End If

'Release the object variables
Set objNameSpace = Nothing
Set objRecipient = Nothing
Set objOutlook = Nothing
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top