Creating an appointment in outlook shared calendar using an access form

what does this do

If Not objRecip.Resolve Then
MsgBox "We have a problem"
End If
 
Your problem is, as I understand it with this line

Set objRecip = objNS.CreateRecipient(strName)
OR
Set objRecip = objNS.CreateRecipient("myemailaddress@email.com")

You need to try a proper email address of someone, try you own. Further test if objRecip is an object of if it is Nothing. Further then to make sure that exchange is up with you code the Resolve just makes sure that exchange recognises the email address. It should return TRUE.
 
Having looking around the code I have noticed that is line

Set objRecip = objNS.CreateRecipient(strName)

after hitting F8 past it it still come up with the following when I put the mouse over it.

objRecip - strName""

objNS.CreateRecipient(strName) - strName""

Am I right in thinking this isn't right and it should be showing mine and someone else email address?
 
strName is a variable = you must either make that variable = to a proper email address OR you need to put

Set objRecip = objNS.CreateRecipient("myemail@enail.com")

The first option allows you to code this with flexibility and change whose email you use.
 
So using the first option:

Set objRecip = objNS.CreateRecipient(strName)

strName should be picked up by this bit thats in the code?:

strName = Me.Text28
 
yes provided that Me.Text28 is a control on your form that contains a properly formatted email address.
 
right cool and yes it's a email address.

so back to earlyer post, so should the following line when I hover mouse over the code show the email thats in that text box? because it doesn't

Set objRecip = objNS.CreateRecipient(strName)
 
That is impossible.

Code:
strName = Me.Text28
Set objRecip = objNS.CreateRecipient(strName)

If you put your mouse over strName and Me.Text28 and it is an email address then strName on the next line must be the same.
 
yeah your right it's impossible, it is there.

still having problems with this line:

Set objFolder = objNS.GetSharedDefaultFolder(objRecip, olFolderCalendar)


Plus I'm now getting a runtime error 91 "Object variable or With block variable not set, on these lines

.Start = Me!AbsenceDateFrom
.End = Me!AbsenceDateTo
.Subject = Me!Subject
If Not IsNull(Me!AbsenceNotes) Then .Body = Me!AbsenceNotes

But when I hover the mouse over each one they do have values.
 
woooo slow down. You are missing some steps out. Your error message means that your appointmentitem object is not working. So is objFolder returning an object? If not then with whos email address are you trying this with? Try it with your own.
 
Ok assuming you have a recipient object then it might not work with your own email address. You then need to get someone to share their calendar with you and for them to give you read AND write rights. Then you use their email address.
 
show your code from the point of getting the namespace to when you start to use your appointment object please.
 
Set objRecip = objNS.CreateRecipient(strName)
If Not objRecip.Resolve Then
On Error Resume Next
End If
Set objFolder = objNS.GetSharedDefaultFolder(objRecip, olFolderCalendar)
If Not objFolder Is Nothing Then
Set objAppt = objFolder.Items.add
If objAppt Is Nothing Then
Set objAppt = objApp.CreateItem(olAppointmentItem)
End If

End If
With objAppt
strName = Me.Text28
.Start = Me!AbsenceDateFrom
.End = Me!AbsenceDateTo
.Subject = Me!Subject
If Not IsNull(Me!AbsenceNotes) Then .Body = Me!AbsenceNotes
.BusyStatus = olOutOfOffice
 
I know that "On Error Resume Next" is in my code somewhere but please understand what it means before using it. It basically means that it will skip through code without showing certain error messages.


Code:
Set objRecip = objNS.CreateRecipient(strName)
If objRecip is Nothing then
    MsgBox "You do not have a recipient"
    Exit Sub
end if
If Not objRecip.Resolve Then
    MsgBox "You have not given a proper email address"
    Exit Sub
End If
Set objFolder = objNS.GetSharedDefaultFolder(objRecip, olFolderCalendar)
If Not objFolder Is Nothing Then
     Set objAppt = objFolder.Items.add
else
   Msgbox "You do not have the right to view this persons calendar"
   Exit Sub
end if
 
Here's a funny one for you.

I used the code you just sent and it worked lovely, but when I went to use it again I'm getting a error again on this line:

Set objFolder = objNS.GetSharedDefaultFolder(objRecip, olFolderCalendar)


Plus strName is now not getting poppulated
 
Here's a funny one for you.

I used the code you just sent and it worked lovely, but when I went to use it again I'm getting a error again on this line:

Set objFolder = objNS.GetSharedDefaultFolder(objRecip, olFolderCalendar)
I have no idea why. Outlook does not having leaks or objects which are not properly cleaned up. It is one of the few MSOffice / VBA things that is not so forgiving. I thus guess that in your testing you are setting outlook objects and then not cleaning them up.

While testing, if you get an error I would suggest that you close your access program totally and close Outlook too. Then check to make sure it all is closed and not still running in Task manager.

The code solution once you get it right is to set all Outlook objects to nothing and make sure you leave the Outlook.Application till last.


Plus strName is now not getting poppulated
That is up to you to find out. Most likely your field on your form is not correct.
 
Think I've found the problem, in the code the line:

Set objFolder = objNS.GetSharedDefaultFolder(objRecip, olFolderCalendar)

is before this line

strName = Me.Text28

and from this line everything else get the email address from, so because it's after the objFolder it's bringing up the runtime error. am I right?
 

Users who are viewing this thread

Back
Top Bottom