automation

G

Guest

I was advised by the access forum to try and find a slution in your forum.
Through the help of the link
http://msdn2.microsoft.com/en-us/library/aa159619(office.11).aspx
on automation I can create through the use of an access form an appointment
in Outlook. When prseeing sent to outlook the appointment is sent and added
automatically to my outlook calendar. My question is does anyone know if
there is a way to add this appointment also to a collegues calendar in the
case we need the go with the 2 of us.
Kind Regards,
Ruud
 
S

Sue Mosher [MVP-Outlook]

Yes, that's possible, but the details depend on your mail environment, your Outlook version, and exactly what you want to do. Do you want to send a meeting request that the other person can accept or turn down? Do you want to create an appointment directly on their calendar (assuming you have such permission over their Exchange mailbox)? Do you want to send them a message with an appointment as an attachment?

FYI, there is a newsgroup specifically for general Outlook programming issues "down the hall" at microsoft.public.outlook.program_vba or, via web interface, at http://www.microsoft.com/office/community/en-us/default.mspx?dg=microsoft.public.outlook.program_vba
 
G

Guest

Thanks Sue for picking up this question.

The matter is we have 2 mailboxes. One is our private and the other is used
for my team. When we currently set-up an appointment through access it goes
directly to the calendar in our private mailbox. I would like to
automatically sent it also to the group mailbox because this would make is
easier for us to check a combined calender for dupe appoinments or if my
partner is available to attend. So he or she should not be able to accept. It
could be added to the groupmailbox. We run on outlook 2002 and we all have
access to the group mailbox. We run on a server, is this the quesion on the
enviroment?

Thanks again for your input.

Kind Regards,
Ruud


Sue Mosher said:
Yes, that's possible, but the details depend on your mail environment, your Outlook version, and exactly what you want to do. Do you want to send a meeting request that the other person can accept or turn down? Do you want to create an appointment directly on their calendar (assuming you have such permission over their Exchange mailbox)? Do you want to send them a message with an appointment as an attachment?

FYI, there is a newsgroup specifically for general Outlook programming issues "down the hall" at microsoft.public.outlook.program_vba or, via web interface, at http://www.microsoft.com/office/community/en-us/default.mspx?dg=microsoft.public.outlook.program_vba
 
S

Sue Mosher [MVP-Outlook]

These are Exchange mailboxes? The code sample at http://www.outlookcode.com/codedetail.aspx?id=43 shows how to create an appointment on the Calendar folder in another user's Exchange mailbox.

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


Ruud said:
Thanks Sue for picking up this question.

The matter is we have 2 mailboxes. One is our private and the other is used
for my team. When we currently set-up an appointment through access it goes
directly to the calendar in our private mailbox. I would like to
automatically sent it also to the group mailbox because this would make is
easier for us to check a combined calender for dupe appoinments or if my
partner is available to attend. So he or she should not be able to accept. It
could be added to the groupmailbox. We run on outlook 2002 and we all have
access to the group mailbox. We run on a server, is this the quesion on the
enviroment?

Thanks again for your input.

Kind Regards,
Ruud
 
G

Guest

Thanks Sue,

I just opened your link and still have a few questions. Do I just past this
under the command which I use to sent it the my private mailbox?
I have added the code
Private Sub cmdAddAppt_Click()
On Error GoTo Add_Err

'Save record first to be sure required fields are filled.
DoCmd.RunCommand acCmdSaveRecord

'Exit the procedure if appointment has been added to Outlook.
If Me!AddedToOutlook = True Then
MsgBox "This appointment is already added to Microsoft
Outlook"
Exit Sub
'Add a new appointment.
Else
Dim objOutlook As Outlook.Application
Dim objAppt As Outlook.AppointmentItem
Dim objRecurPattern As Outlook.RecurrencePattern

Set objOutlook = CreateObject("Outlook.Application")
Set objAppt = objOutlook.CreateItem(olAppointmentItem)

With objAppt
.Start = Me!ApptDate & " " & Me!ApptTime
.Duration = Me!ApptLength
.Subject = Me!Appt

If Not IsNull(Me!ApptNotes) Then .Body = Me!ApptNotes
If Not IsNull(Me!ApptLocation) Then .Location =
Me!ApptLocation
If Me!ApptReminder Then
.ReminderMinutesBeforeStart = Me!ReminderMinutes
.ReminderSet = True
'End If

'Set objRecurPattern = .GetRecurrencePattern

'With objRecurPattern
' .RecurrenceType = olRecursWeekly
' .Interval = 1
'Once per week
' .PatternStartDate = #12/19/2003#
' .PatternStartDate = Me!ApptStartDate
'You could get these values
'from new text boxes on the form.
' .PatternEndDate = #7/23/2003#
' .PatternEndDate = Me!ApptEndDate
' End With

.Save
.Close (olSave)
'End With
'Release the AppointmentItem object variable.
Set objAppt = Nothing
End If

'Release the Outlook object variable.
Set objOutlook = Nothing

'Set the AddedToOutlook flag, save the record, display a message.
Me!AddedToOutlook = True
DoCmd.RunCommand acCmdSaveRecord
MsgBox "Appointment Added!"

Exit Sub

Add_Err:
MsgBox "Error " & Err.Number & vbCrLf & Err.Description
Exit Sub

End With
End If
End Sub


ALso in the name of the mailbox IstrName = "FlaviusJ" I just replace
FlaviusJ with the e-mail address of the mailbox

Set objDummy = objApp.CreateItem(olMailItem) should this be oiappointmentitem

Sorry to ask so many questions.

Kind Regards,
Ruud
 
S

Sue Mosher [MVP-Outlook]

You'd probably want to integrate it into your existing procedure, so that you avoid as much code duplication as possible.

The purpose of this statement:

Set objDummy = objApp.CreateItem(olMailItem) should this be oiappointmentitem

is to create a message from which you can get a resolved Recipient object to pass as a parameter for the GetSharedDefaultFolder method. But a simpler approach (and one that wouldn't raise securitiy prompts) would be to use the Application.CreateRecipient method from the Outlook object model.
--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


Ruud said:
Thanks Sue,

I just opened your link and still have a few questions. Do I just past this
under the command which I use to sent it the my private mailbox?
I have added the code
Private Sub cmdAddAppt_Click()
On Error GoTo Add_Err

'Save record first to be sure required fields are filled.
DoCmd.RunCommand acCmdSaveRecord

'Exit the procedure if appointment has been added to Outlook.
If Me!AddedToOutlook = True Then
MsgBox "This appointment is already added to Microsoft
Outlook"
Exit Sub
'Add a new appointment.
Else
Dim objOutlook As Outlook.Application
Dim objAppt As Outlook.AppointmentItem
Dim objRecurPattern As Outlook.RecurrencePattern

Set objOutlook = CreateObject("Outlook.Application")
Set objAppt = objOutlook.CreateItem(olAppointmentItem)

With objAppt
.Start = Me!ApptDate & " " & Me!ApptTime
.Duration = Me!ApptLength
.Subject = Me!Appt

If Not IsNull(Me!ApptNotes) Then .Body = Me!ApptNotes
If Not IsNull(Me!ApptLocation) Then .Location =
Me!ApptLocation
If Me!ApptReminder Then
.ReminderMinutesBeforeStart = Me!ReminderMinutes
.ReminderSet = True
'End If

'Set objRecurPattern = .GetRecurrencePattern

'With objRecurPattern
' .RecurrenceType = olRecursWeekly
' .Interval = 1
'Once per week
' .PatternStartDate = #12/19/2003#
' .PatternStartDate = Me!ApptStartDate
'You could get these values
'from new text boxes on the form.
' .PatternEndDate = #7/23/2003#
' .PatternEndDate = Me!ApptEndDate
' End With

.Save
.Close (olSave)
'End With
'Release the AppointmentItem object variable.
Set objAppt = Nothing
End If

'Release the Outlook object variable.
Set objOutlook = Nothing

'Set the AddedToOutlook flag, save the record, display a message.
Me!AddedToOutlook = True
DoCmd.RunCommand acCmdSaveRecord
MsgBox "Appointment Added!"

Exit Sub

Add_Err:
MsgBox "Error " & Err.Number & vbCrLf & Err.Description
Exit Sub

End With
End If
End Sub


ALso in the name of the mailbox IstrName = "FlaviusJ" I just replace
FlaviusJ with the e-mail address of the mailbox

Set objDummy = objApp.CreateItem(olMailItem) should this be oiappointmentitem

Sorry to ask so many questions.

Kind Regards,
Ruud
 
G

Guest

Sue,
I believe to have it in one procedure would sound the easiest way to me. The
suggestions you made on the Application.CreateRecipient method from the
Outlook object model does not say much to me. Also I know the e-mailaddress
of the group mailbox but have no idea if thsi is the correct name nor where I
could find the name of the mailbox. I noticed an exchange server name, is
this something I should use in stead of FlaviusJ

Kind Regards,
Ruud
 
S

Sue Mosher [MVP-Outlook]

If there's something about the CreateRecipient or GetSharedDefaultFolder method you don't understand (sorry, but I can't read your mind to guess what you're thinking about), you can look up that method in Outlook VBA Help for more info. It can take an SMTP address or a user name or a mailbox alias -- anything that can be *uniquely* resolved to an Exchange user recipient.
--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54
 
G

Guest

Sue,
I realize it is 4th of Juli but you are not celibrating or enjoying your day
off.

I did not want the offend you and know it is hard to understand what iám
thinking or want to achieve. I have no idea what I should or can do nor what
these commands mean.
I just copied the vba and ammended the codes with the fields I use in the
Access Tables

Should I just copy the given code to the existing one and change the name?

Kind Regards,
Ruud
 
S

Sue Mosher [MVP-Outlook]

Actually, I'm enjoying the day very much. Pleasant breezes and no pressures. And the Nats are ahead of the Cubs 6-0 on a grand slam.

Your original post suggested that you have some experience in writing code. I gave you the code for a technique to add an appointment to another user's folder. I'm happy to answer specific questions, but this is the only one I have on the agenda:
Should I just copy the given code to the existing one and change the name?

and I don't know what "to the existing one" means. Again, if you want one procedure that creates two appointments in two different calendars, you need to incorporate the two techniques you've seen into one subroutine. In other words, you need to take the code statements that perform the desired operation from one procedure and insert them into the other procedure in such a way that you don't duplicate things, like instantiating an Outlook.Application object twice, adjusting variable names as needed.

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

Guest

In the last Inning? I'am living in Amsterdam, so bizz is as usual. Glad you
are enjoing your day. So I guess I fooled you, i'am certeinly not an expert
on VBA but love improving myself. The current code I took from the
automation info in the access link.This adds an appointment to the calendar
in my private mailbox. I would like to have the appointment with the same
procedure directly added to the group mailbox.
If you would be so kind in copying the code and getting the address i would
be very gratefull.

What I mean with the existing one is the appointment added to the mailbox
with code I sent you. So it is one appointment into two calendars

I hope this helps and explains.

Kind Regards,
Ruud
 
S

Sue Mosher [MVP-Outlook]

I'm not really into writing someone's code project for them. It makes me very nervous, because it means if something goes wrong and they don't understand it, they won't be able to fix it. I'd rather you give it a try, post the results and then let us help you understand it and fix any problems.

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

Guest

Sue,

If it wouln't work I would delete it and start over again and use the back
up.. So don't worry.
 
G

Guest

Sue, I understand your concern.
One last Question if you see the vba code I have provided.As no specific
information on the address is mentioned where and how would you put in the
group mailbos or the e-mail address spedifying to what mailbox it should go.
In this case I would only sent it the one mailbox.
--
Kind Regards,
Ruud


Ruud said:
Thanks Sue,

I just opened your link and still have a few questions. Do I just past this
under the command which I use to sent it the my private mailbox?
I have added the code
Private Sub cmdAddAppt_Click()
On Error GoTo Add_Err

'Save record first to be sure required fields are filled.
DoCmd.RunCommand acCmdSaveRecord

'Exit the procedure if appointment has been added to Outlook.
If Me!AddedToOutlook = True Then
MsgBox "This appointment is already added to Microsoft
Outlook"
Exit Sub
'Add a new appointment.
Else
Dim objOutlook As Outlook.Application
Dim objAppt As Outlook.AppointmentItem
Dim objRecurPattern As Outlook.RecurrencePattern

Set objOutlook = CreateObject("Outlook.Application")
Set objAppt = objOutlook.CreateItem(olAppointmentItem)

With objAppt
.Start = Me!ApptDate & " " & Me!ApptTime
.Duration = Me!ApptLength
.Subject = Me!Appt

If Not IsNull(Me!ApptNotes) Then .Body = Me!ApptNotes
If Not IsNull(Me!ApptLocation) Then .Location =
Me!ApptLocation
If Me!ApptReminder Then
.ReminderMinutesBeforeStart = Me!ReminderMinutes
.ReminderSet = True
'End If

'Set objRecurPattern = .GetRecurrencePattern

'With objRecurPattern
' .RecurrenceType = olRecursWeekly
' .Interval = 1
'Once per week
' .PatternStartDate = #12/19/2003#
' .PatternStartDate = Me!ApptStartDate
'You could get these values
'from new text boxes on the form.
' .PatternEndDate = #7/23/2003#
' .PatternEndDate = Me!ApptEndDate
' End With

.Save
.Close (olSave)
'End With
'Release the AppointmentItem object variable.
Set objAppt = Nothing
End If

'Release the Outlook object variable.
Set objOutlook = Nothing

'Set the AddedToOutlook flag, save the record, display a message.
Me!AddedToOutlook = True
DoCmd.RunCommand acCmdSaveRecord
MsgBox "Appointment Added!"

Exit Sub

Add_Err:
MsgBox "Error " & Err.Number & vbCrLf & Err.Description
Exit Sub

End With
End If
End Sub


ALso in the name of the mailbox IstrName = "FlaviusJ" I just replace
FlaviusJ with the e-mail address of the mailbox

Set objDummy = objApp.CreateItem(olMailItem) should this be oiappointmentitem

Sorry to ask so many questions.

Kind Regards,
Ruud
 
S

Sue Mosher [MVP-Outlook]

That's the purpose of this statement, documented in the code sample with a comment:

' ### name of person whose Calendar you want to use ###
strName = "FlaviusJ"

It can be the name, the mailbox alias, or the SMTP address but it must be uniquely resolvable. In other words, if you type it into the To box and do Check Names, it has to turn into the underlined name.
--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54
 

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