Page 1 of 2 12 LastLast
Results 1 to 15 of 25
  1. #1
    Aweiher is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2016
    Posts
    25

    Export with Outlook Invite as attachment?

    I have a database that tracks the schedule for multiple employees. When the data entry screen for an appointment is closed it fires a VBA code that sends the assigned employee a summery of the appointment.



    Here is the code I use.
    DoCmd.SendObject , , , [teemail], , , "You have a new schedule item.", "Type of Appointment: " & [totDescription] & vbCrLf & vbCrLf & "Date: " & [tblSchedule.scDate] & vbCrLf & "Start Time: " & [scStartTime] & vbCrLf & vbCrLf & "End Time: " & [scEndTime] & vbCrLf & vbCrLf & "Project Number: " & [prProjectNumber] & vbCrLf & "Project Name: " & [prName] & vbCrLf & vbCrLf & "Location: " & [scLocation] & vbCrLf & "Directions/Map: " & slink & vbCrLf & vbCrLf & "Contractor: " & [coName] & vbCrLf & vbCrLf & "Material Info: " & [scMaterialInformation] & vbCrLf & vbCrLf & "Inspector: " & [inFullName] & vbCrLf & "Email: " & [inEmail] & vbCrLf & "Cell: " & [inCell] & vbCrLf & vbCrLf & "Remarks: " & [tblSchedule.scNotes], 0

    My question is, can I have that email also include an outlook appointment invite attached to the email that would have the Date (tblSchedule.scDate), Start Time (scStartTime), End Time (scEndTime), Subject (totDescription), and Location (scLocation) already filled out, so the user can just open the attachment and click "Accept"?

  2. #2
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,441
    enclose your code in to make it readable please.

    You can do pretty much anything with an outlook object that you could with a mouse and keyboard, however I don't know if you can do it with the .sendobject command. .sendobject is a lot more restricted than using outlook objects.

  3. #3
    vicsaccess's Avatar
    vicsaccess is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Apr 2015
    Posts
    451
    I have that on my list of things that would be "great" to add to my DB at a later time so i have this code and article saved to look into later. maybe it can do you some good now. let me know how it works.

    http://gainingaccess.net/Articles/Ac...kCalendar.aspx

  4. #4
    Aweiher is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2016
    Posts
    25
    Thanks for the replies. Vicaccess I'll check that out. rpeare how to I enclose code? sorry I'm new to the forum.

  5. #5
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,441
    put
    Code:
     before your code and
    after your code

  6. #6
    Aweiher is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2016
    Posts
    25
    Code:
    testing
    <

  7. #7
    Aweiher is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2016
    Posts
    25
    I can't see what you put to enclose it...

  8. #8
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,441
    arg it's a a square bracket [ ] on both sides of your code in one it says 'code' the terminator says /code

  9. #9
    Aweiher is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2016
    Posts
    25
    vicsaccess I tried that code out. It worked with the exception of 1) the .duration property; I had to delete that to get the code to fire, and 2) the code to check to see if outlook is open doesn't seem to work.

    I will def add that button my database, but I'm still searching for a way for the email a person receives to contain the outlook appointment as an attachment.

  10. #10
    Aweiher is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2016
    Posts
    25
    Heres the code I ended up using
    [Code:]Private Sub Command374_Click()
    If Me.Dirty Then
    Me.Dirty = False
    End If

    Dim olapp As Object ' Outlook.Application
    Dim olappt As Object ' olAppointmentItem

    'If isAppThere("Outlook.Application") = False Then
    ' Outlook is not open, create a new instance
    'Set olapp = CreateObject("Outlook.Application")
    'Else
    ' Outlook is already open--use this method
    Set olapp = GetObject(, "Outlook.Application")
    'End If
    Set olappt = olapp.CreateItem(1) ' olAppointmentItem
    With olappt
    .Start = Nz(Me.scDate, "") & " " & Nz(Me.scStartTime, "")
    .End = Nz(Me.scDate, "") & " " & Nz(Me.scEndTime, "")
    .Location = Nz(Me.scLocation, vbNullString)
    .Subject = Nz(Me.totDescription, vbNullString)
    .Body = Nz(Me.scNotes, vbNullString)
    '.ReminderOverrideDefault = True
    '.ReminderMinutesBeforeStart = 30
    '.ReminderSet = True
    .Save
    End With

    ' Release the Outlook object variables.
    Set olappt = Nothing
    Set olapp = Nothing

    ' Inform the user
    MsgBox "Appointment Added!", vbInformation

    End Sub
    [/code]

  11. #11
    Aweiher is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2016
    Posts
    25
    And clearly I don't know wtf im doing when it comes to embedding code in this forum....

  12. #12
    vicsaccess's Avatar
    vicsaccess is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Apr 2015
    Posts
    451
    Thanks for the update, someday i'll get around to this code. hopefully you can get the bugs worked out for me

  13. #13
    Aweiher is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2016
    Posts
    25
    Ok I found different code that successfully checks if outlook is open
    Code:[ Dim oOutlook As Object
    On Error Resume Next
    Set oOutlook = GetObject(, "Outlook.Application")
    On Error GoTo 0
    If oOutlook Is Nothing Then
    ' Outlook is not open, create a new instance
    Set olapp = CreateObject("Outlook.Application")
    Else
    ' Outlook is already open--use this method
    Set olapp = GetObject(, "Outlook.Application")
    End If /code]

  14. #14
    vicsaccess's Avatar
    vicsaccess is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Apr 2015
    Posts
    451
    still curious, were you able to get it to email the appointments?

  15. #15
    sstiebinger is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Mar 2015
    Posts
    105
    You can use the "#" button in the editor to generate the code brackets.
    [C0DE]Your code here.[/C0DE]

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Add attachment to Outlook Email from Table?
    By floyd in forum Programming
    Replies: 3
    Last Post: 11-27-2013, 12:04 PM
  2. Replies: 5
    Last Post: 10-08-2013, 08:16 AM
  3. Replies: 1
    Last Post: 04-01-2013, 05:00 PM
  4. Send email in Outlook with attachment
    By kelkan in forum Programming
    Replies: 1
    Last Post: 02-01-2013, 10:31 PM
  5. Excel attachment and save as draft in outlook
    By ragsgold in forum Programming
    Replies: 1
    Last Post: 02-01-2013, 05:55 PM

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