5

When I manually make a calendar reminder/appointment, I can then click "Invite Attendees" and chose the people to invite and then click "Send" and everyone will receive that calendar reminder/appointment.

I have the following code to make a reminder programmatically, but it won't send to the intended recipients. If I open the reminder after the script has run and click on "Invite Attendees" I can see the list is filled with the people I want to send the reminder to, so I'm not really sure why it's not actually sending the reminder to them.

Can anyone shed some light on this for me?

Private Function CreateAppointment(SubjectStr As String, BodyStr As String, StartTime As Date, EndTime As Date, AllDay As Boolean)
    Dim olApp As Outlook.Application
    Dim Appt As Outlook.AppointmentItem
    ' Only create the reminder if there's no duplicate
    If (CheckForDuplicates(SubjectStr) = False) Then
        Set olApp = CreateObject("Outlook.Application")
        Set Appt = olApp.CreateItem(olAppointmentItem)
        Appt.Recipients.Add ("John Doe")
        Appt.Recipients.ResolveAll
        Appt.Subject = SubjectStr
        Appt.Start = StartTime
        Appt.End = EndTime
        Appt.AllDayEvent = AllDay
        Appt.Body = BodyStr
        Appt.ReminderSet = True
        Appt.Save
        Appt.Send
    End If
    Set Appt = Nothing
    Set olApp = Nothing
End Function
Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
FizzBuzz
  • 558
  • 2
  • 13
  • 29
  • Hm, yeah, I see what you mean! Just tried it. I don't know why it doesn't get sent! +1 useful question. – Jean-François Corbett Sep 30 '11 at 08:58
  • Same here. I saw a property called "SendUsingAccount" where you can set like this: _Application.Session.Accounts(1)_ . You'd do this before you saved the item. It still had no effect. I changed accounts (e.g. tried it on my pop3 instead of company Exchange server). Also, I loaded up a Virtual Instance of Windows 2000 and Outlook XP and tried it there. No luck and no response why it didn't work. :P The funny thing is on Windows 2000 I was getting a security popup on the send line saying "This app is about to try to send something. Do you want to allow?" I say allow but nothing. – ray Sep 30 '11 at 15:02
  • That's better than I've managed to get even. Macro security denotes any send function must notify user before sending, so you must have done something semi-right... Hopefully someone will come across this and have an answer for us. – FizzBuzz Oct 01 '11 at 03:39
  • The code works fine, tested in Outlook 2010. I removed the `If (CheckForDuplicates(SubjectStr) = False) Then` If statement because that was not listed. Note that due to security, some things can **only** be done in VBA via putting your code in "VbaProject.OTM". If you put it elsewhere, it will fail. – Todd Main Oct 05 '11 at 16:59

2 Answers2

5

A meeting is a specific type of appointment -- an appointment that other people are invited to.

In order to make an appointment a meeting, you need to do more than just invite attendees. You need to set the status to 'Meeting'. Add this to your code:

Appt.MeetingStatus = olMeeting

Also note that you set a reminder, but didn't set a reminder time. For example,

Appt.ReminderMinutesBeforeStart = 30

Finally, if this is Outlook VBA, why are you using CreateObject? You should be using the native Application Object to derive all your objects.

i.e. instead of

Set olApp = CreateObject("Outlook.Application")

you would use

Set olApp = Outlook.Application

HTH

JimmyPena
  • 8,694
  • 6
  • 43
  • 64
0

I had the same issue, didn't get it to work until I replaced

Appt.Recipients.Add ("John Doe")
Appt.Recipients.ResolveAll

With

Appt.RequiredAttendees = "john.doe@email.com"

Regards

Chris

Chris
  • 1