Problem adding an attachment field to Outlook appointment

BrotherBook

Registered User.
Local time
Today, 18:49
Joined
Jan 22, 2013
Messages
43
Hi-

I've created some VBA to add appointment information contained in my database to a user's outlook calendar. The code works perfectly until I tried to include an attachment in the appointment using an attachment field in my database. I've scoured Google and these forms to try and find a solution, but I have been unable to find anything. Below is my code which receives Run Time error 438, "Object does not support the property or method" when trying to run ".attachments.add (Me.Agenda)".

Code:
'Exit the procedure if the appointment has already been added
If Me.AddedToOutlook = True Then
MsgBox ("This appointment has already been added to Outlook.")
Exit Sub
'Add a new appointment
Else
    Dim objOutlook As Outlook.Application
    Dim objAppt As Outlook.AppointmentItem
    
    Set objOutlook = CreateObject("Outlook.Application")
    Set objAppt = objOutlook.CreateItem(olAppointmentItem)
    
    With objAppt
    .Start = Me.AppointmentDate & " " & Me.AppointmentTime
    .Duration = Me.Duration
    .Subject = [Forms]![Menu]![ProspectListing].Column(1) & " (" & Me.ContactName & ")"
    .Attachments.Add (Me.Agenda)
    .Body = BodyString
    .ReminderMinutesBeforeStart = 15
    .ReminderSet = True
    .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 to Outlook")
 
I have determined that the .attachments within the Appointment is just a read only property so that is why I have been getting the error. However, I haven't been able to get an attachment to pass through.
 
Hello BrotherBook,

I am not completely sure of Attachments in Access.. As I avoid using them.. My general understanding of Attachments in MS Access is that, when you add an attachment, the whole file is uploaded and stored as an Object. This object can be view by using the local applications like MS Word, PDF Reader etc.

That is the reason your Attachment fails.. Simple way to achieve attachments is to have a organised structure (Hyperlinks) to store all files under the Server/Shared Network location, thus allowing the file URL to be used for attachment.. Long way to go around is to Save the attachments to local drives and then use that location for attaching files on Oulook... But I have not worked with this so I am not sure how this code will work for you..

Sorry I could not be of great help..
 

Users who are viewing this thread

Back
Top Bottom