Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1425
  • Last Modified:

Send invitation request from Access

Dear Experts
Courtesy of EE I have adapted a piece of code which creates an outlook calendar appointment - this works all ok, but what I am keen to do is is be able to automatically send out meeting requests as part of the code.  

I've managed to create the outlook appointment and put in the required attendees (these do appear when I open the appointment in Oulook) - this all works ok, but the invitations arent sent

The code I'm using is below:

Private Sub CreateiCal_Click()

DoCmd.Save
    
    Dim InvoiceDate1 As String
    InvoiceDate1 = Me.Invoice_Date_1 - 2
    
    
            Dim objOutlook As Outlook.Application
        Dim objAppt As Outlook.AppointmentItem
     

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

        With objAppt
            .Start = InvoiceDate1 & " " & "09:00"
            .Duration = 0
            .Subject = "Invoice for " & Me.HeaderLabel1 & " for " & Me.title & " at " & Me.Firm & " due to be sent in 2 days"

            .Body = Me.HeaderLabel1 & " fee is due in 2 days for the following assignment: " & vbCr & "Firm: " & "Role: " & Me.title & vbCr & "Amount: " & Me.Date_Invoice_Amount_1
            .Location = "Desk"
        
           .RequiredAttendees = "xxx@hotmail.com"

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

    'Release the Outlook object variable.
    Set objOutlook = Nothing

    MsgBox "Appointment Added!"

    Exit Sub


End Sub

Open in new window


Can anybody help?
0
correlate
Asked:
correlate
  • 6
  • 4
2 Solutions
 
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
Have you tried stepping through the code to insure that you hit the Send line?

Might also try including an End date/time:

.End = InvoiceDate1 & " " & "11:00"

You also might include the Date delimiter with those values:

.End = "#" & InvoiceDate1 & " " & "11:00#"

And the same for Start
0
 
correlateAuthor Commented:
Hi,

Thanks for that, it appears that .send is ineffective, it simply does nothing. The other route i was thinking was to somehow export this to an ical & attach that to an email, but not sure where to begin on that - any ideas?
0
 
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
Does this create an Appointment and just not Send it?
0
NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

 
correlateAuthor Commented:
yep thats it it creates it but doesnt send
0
 
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
Just for kicks, try removing the .Close line ...
0
 
correlateAuthor Commented:
tried that & alas nothing happens - the appointment doesnt save & also no invitations are sent
0
 
correlateAuthor Commented:
Got it to work ....

DoCmd.Save
    
Dim InvoiceDate1 As String
InvoiceDate1 = Me.Invoice_Date_1 - 2

Dim objOApp As New Outlook.Application
Dim objAppt As AppointmentItem
Dim oExp As Outlook.Explorer


Set objOApp = New Outlook.Application
Set objAppt = objOApp.CreateItem(olAppointmentItem)
Set oExp = objOApp.Session.GetDefaultFolder(olFolderInbox).GetExplorer

With objAppt
.RequiredAttendees = "xxx@hotmail.com"
.Subject = "Invoice for " & Me.HeaderLabel1 & " for " & Me.title & " at " & Me.Firm & " due to be sent in 2 days"

.Start = InvoiceDate1 & " " & "09:00"
.End = InvoiceDate1 & " " & "09:00"
.Location = "Desk"
.Body = Me.HeaderLabel1 & " fee is due in 2 days for the following assignment: " & vbCr & "Firm: " & "Role: " & Me.title & vbCr & "Amount: " & Me.Date_Invoice_Amount_1
.MeetingStatus = 1
.ResponseRequested = True
.Save 'Uncomment if you want message saved to your sent items
.Send
MsgBox "Item sent."
End With


Exit_btnSendItem_Click:
Set objOApp = Nothing
Set objAppt = Nothing
Set oExp = Nothing
Exit Sub

End Sub

Open in new window


Think we were missing:

Set objOApp = New Outlook.Application
Set objAppt = objOApp.CreateItem(olAppointmentItem)
Set oExp = objOApp.Session.GetDefaultFolder(olFolderInbox).GetExplorer

Many thanks for your help looking into this one
0
 
correlateAuthor Commented:
Ok by me
0
 
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
Cool ... glad you got it to work!
0
 
correlateAuthor Commented:
Add it in so opther users can see it quickly, LSMConsulting helped in 2 ways - tidying up & most importantly getting me to think about the problem in bite size chunks by breaking down & testing each component part.
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

  • 6
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now