Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2015
    Location
    Wales. Land of the sheep.
    Posts
    1,228

    VBA to add outlook apointments.

    The bit I need help with here isn't actually in access, but its possible it will help others using access, as the data I'm using here is in an excel table linked to the database. (if there is a better way please let me know.)



    Basically I have a table in excel with data I want on an outlook calendar. Most of this is working thanks to some help, but I'm doing something wrong here. Here is the code:

    Code:
    Private Sub CreateAppointment(ws As Excel.Worksheet, lngRow As Long)
       Dim oAppt            As Object                     'Outlook.AppointmentItem
       Dim blnCreated       As Boolean
       Dim oFolder          As Object                     'Outlook.MAPIFolder
       Dim lngAddRow        As Long
       'On Error Resume Next
       Set oFolder = oNS.GetDefaultFolder(&H9)            ' olFolderCalendar
       Set oAppt = oFolder.Items.Add(&H1)                 '   olAppointmentItem
       Application.StatusBar = "Adding " & ws.Cells(lngRow, 1).Value
       With oAppt
          'Define calendar item properties
          .Start = ws.Cells(lngRow, 7).Value + ws.Cells(lngRow, 8).Value
          '.End = ws.Cells(lngRow, 7).Value + TimeValue("01:00:00")
          .Subject = ws.Cells(lngRow, 1).Value
          .Location = ws.Cells(lngRow, 6).Value
          .AllDayEvent = True
          .Body = "Hardwired signals: "
          .BusyStatus = False
          '.ReminderMinutesBeforeStart = ws.Cells(lngRow, 7).Value - TimeValue("00:30:00")
          .ReminderSet = False
          .Categories = shtImport.Range("CategoryName").Value
          '.Send = "test@test.com"
          .Save
    All the code works fine except for the bit I've added. Where it says .send and the test email. I cant get this working at all. I want all new appointments to be sent to a default email for tracking purposes. (they will be dealt with there via outlook rules.)

    Hope someone can advise.

  2. #2
    Join Date
    Jun 2015
    Location
    Wales. Land of the sheep.
    Posts
    1,228
    some progress,

    Code:
    .RequiredAttendees = "test@test.com"
            .Send
    this doesn't break the code.. and it also puts the email in the "to:" field when I click invite attendees I can see it.

    BUT, I don't receive the email. Also on the calendar the tracking option isn't at the top. so obviously its not been sent. Getting closer. Help appreciated.


    inserting this causes the error: variable not defined.
    Code:
    .MeetingStatus = olMeeting


    Const olMeeting = 1 fixed it... thanks for the help! haha.

  3. #3
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Thanks for posting back with your success and solution aand marking the thread as Solved. Sometimes all you need is a sounding board.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. MS Outlook
    By RayMilhon in forum Misc
    Replies: 6
    Last Post: 01-15-2016, 02:50 PM
  2. Replies: 0
    Last Post: 12-15-2014, 08:18 AM
  3. Outlook
    By donillo in forum Programming
    Replies: 12
    Last Post: 07-23-2014, 09:53 AM
  4. Replies: 11
    Last Post: 05-20-2014, 11:32 AM
  5. Assigning Outlook task from shared Outlook mailbox
    By Remster in forum Programming
    Replies: 2
    Last Post: 11-16-2011, 04:38 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums