Help!

Problems with Outlook.Recipient.Resolve

 
  

Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> Programming VBA RSS
Next:  2007 Outlook calendar and updates in the master c..  
Author Message
JoD
External


Since: Jul 12, 2006
Posts: 3



PostPosted: Thu Sep 10, 2009 8:52 am    Post subject: Problems with Outlook.Recipient.Resolve
Archived from groups: microsoft>public>outlook>program_vba (more info?)

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
Back to top
Sue Mosher [MVP]
External


Since: Mar 19, 2009
Posts: 41



PostPosted: Thu Sep 10, 2009 12:02 pm    Post subject: Re: Problems with Outlook.Recipient.Resolve [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

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" <JoD RemoveThis @discussions.microsoft.com> wrote in message
news:A2BF1308-D340-4B87-A5C8-447232968165@microsoft.com...
>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
>
Back to top
JoD
External


Since: Jul 12, 2006
Posts: 3



PostPosted: Thu Sep 10, 2009 12:02 pm    Post subject: Re: Problems with Outlook.Recipient.Resolve [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

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

Thanks!

"Sue Mosher [MVP]" wrote:

> 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" <JoD.RemoveThis@discussions.microsoft.com> wrote in message
> news:A2BF1308-D340-4B87-A5C8-447232968165@microsoft.com...
> >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
> >
>
>
>
Back to top
Sue Mosher [MVP]
External


Since: Mar 19, 2009
Posts: 41



PostPosted: Thu Sep 10, 2009 1:04 pm    Post subject: Re: Problems with Outlook.Recipient.Resolve [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

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" <JoD.DeleteThis@discussions.microsoft.com> wrote in message
news:32E2203C-7CFA-44C4-AAD7-BC9F35E49F70@microsoft.com...
> Could you kindly show me an example of what you mean? I'm not sure where
> the
> "=" would go.
>
> Thanks!
>
> "Sue Mosher [MVP]" wrote:
>
>> Try prefixing each one with "=" to force Outlook to perform an exact
>> match
>> on the name when it tries to resolve.
>>
>> "JoD" <JoD.DeleteThis@discussions.microsoft.com> wrote in message
>> news:A2BF1308-D340-4B87-A5C8-447232968165@microsoft.com...
>> >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
>> >
>>
>>
>>
Back to top
Display posts from previous:   
Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> Programming VBA All times are: Eastern Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum