Outlook Appointment not sending (1 Viewer)

Nous1970

New member
Local time
Today, 07:52
Joined
Feb 18, 2018
Messages
21
I have created a function to place appointments in my outlook calendar and this all works well.
The only issue is that it is not sending an email to the attendees and I can't seem to figure out why.
Even when I open the appointment, created in my calendar, the email address is there.
I have tried .display as well, however this just displayed the appointment but I still had to send it manually.
Any help would be appreciated.

The code is as followed.

CODE IS UPDATED AND IS WORKING CODE NOW!

Code:
Public Function UpdateOutlook()

    Dim oRS As DAO.Recordset
    Dim oOL As Outlook.Application
    Dim oAppoint As Outlook.AppointmentItem
    Dim sStart As String
    Dim Port As String
    Dim myRequiredAttendee As Outlook.Recipient
 
 
    Set oRS = CurrentDb.OpenRecordset("ShipVissitReportQ")
    Set oOL = New Outlook.Application
    Set oAppoint = oOL.CreateItem(olAppointmentItem)
 
    oRS.FindFirst "ShipsVisitID=" & CurID
    OutlookSubj = oRS.Fields("VesselName") & " - OCEANIC SERVICES VESSEL VISIT REQUEST. - " & oRS.Fields("PortName")
   
    With oAppoint
 
        If IsNull(oRS.Fields("VisitDate")) Then
            GoTo NoDate
        Else
            sStart = oRS.Fields("VisitDate") & " " & oRS.Fields("VisitTime")
        End If

        .Start = CDate(sStart)
        .Duration = 240
        .subject = OutlookSubj
     
        If Not IsNull(oRS.Fields("Remarks")) Then
            .Body = oRS.Fields("Remarks")
        End If
     
        Set myRequiredAttendee = .Recipients.Add("xxxxxxxx@gmail.com")
        myRequiredAttendee.Type = olRequired
     
        If IsNull(Forms!ShipVisitOverviewF!PortName) Then
            MsgBox "there is no port assigned"
        Else
            MsgBox "there is port assigned!!!!"
            .Location = oRS.Fields("PortName")
                oRS.Edit
                oRS!PortAss = True
                oRS.Update
        End If
     
        .Categories = "Oceanic-Services"
        .MeetingStatus = olMeeting 'this has been changed from olNonMeeting for it to work.
        .Save
     
        oRS.Edit
        oRS!GlobalAppointmentID = .GlobalAppointmentID
        oRS.Update
           
    End With
 
    oAppoint.Send

    GoTo EndFunc
 
NoDate:
    MsgBox "No date entered"

EndFunc:
    oRS.Close
 
    Set oRS = Nothing
    Set oOL = Nothing
    Set oAppoint = Nothing

End Function
 
Last edited:
Solution
I figured out where I went wrong, and it was actually very simple :)
I only had to change the meeting status.
Code:
.MeetingStatus = olNonMeeting

to
Code:
.MeetingStatus = olMeeting

and everything worked perfect now :)

Thanks to your code, I noticed where I went wrong.

(y)(y)

Nous1970

New member
Local time
Today, 07:52
Joined
Feb 18, 2018
Messages
21
Thank you for the reply.

Yes I did, and then it just openen but did not send is.
I still had to send it manually by pressing send
 

Nous1970

New member
Local time
Today, 07:52
Joined
Feb 18, 2018
Messages
21
No worries. Thank you for looking at it.

The .save is in the with statement.
I moved the .send out of the with statement as a last try to make it work.

But so far no luck 😕
 
Last edited:

Gasman

Enthusiastic Amateur
Local time
Today, 06:52
Joined
Sep 21, 2011
Messages
14,299
You do not appear to have Option Explicit set? :(

Just tried your code with rs commented out and it fails.
OutlookSubj is not declared?

After fixing that it does not send, but does save.
When I go into the appointment I can save and send, but then it complains 'No recipients'?

I think that is your problem, you are not using the correct properties.? :(

Edit: Still not sending though. :(
 
Last edited:

Nous1970

New member
Local time
Today, 07:52
Joined
Feb 18, 2018
Messages
21
Yes I have option explicit set

Code:
Option Compare Database
Option Explicit

The saving is not the issue.
The appointment gets into outlook.
Also the email address is in the appointment.
The only thing it doesn't do is the send part.

When I open the appointment and click on the scheduling assistant the email address is there or if I press invite attendees the email is also there as well.

I just doesn't send through the vba.
When I press send in outlook it does send as it should.

:cry:
 

Gasman

Enthusiastic Amateur
Local time
Today, 06:52
Joined
Sep 21, 2011
Messages
14,299
So where is OutlookSubj declared?
Is that a Global?

Anyway, even when I got mine to run and use .Recipients, it still did not send, so unable to help, Sorry again. :(

Edit: FWIW the code from that link, modified to work (names, objects etc) works fine and puts it in the outbox. :unsure:
Code:
Sub CreateAppt()
 Dim myItem As Object
 Dim myRequiredAttendee, myOptionalAttendee, myResourceAttendee As Outlook.Recipient
     Dim oRS As DAO.Recordset
    Dim oOL As Outlook.Application
    Dim oAppoint As Outlook.AppointmentItem
    Dim sStart As String
    Dim Port As String
    'Dim myRequiredAttendee As Outlook.Recipient
    
    
    'Set oRS = CurrentDb.OpenRecordset("ShipVissitReportQ")
    Set oOL = New Outlook.Application
    'Set oAppoint = oOL.CreateItem(olAppointmentItem)

 
 Set myItem = oOL.CreateItem(olAppointmentItem)
 myItem.MeetingStatus = olMeeting
 myItem.Subject = "Strategy Meeting"
 myItem.location = "Conf Rm All Stars"
 myItem.start = Now() + 0.25
 myItem.duration = 90
 Set myRequiredAttendee = myItem.Recipients.Add("xxxxxx@gmail.com")
 myRequiredAttendee.Type = olRequired
' Set myOptionalAttendee = myItem.Recipients.Add("Kevin Kennedy")
' myOptionalAttendee.Type = olOptional
' Set myResourceAttendee = myItem.Recipients.Add("Conf Rm All Stars")
' myResourceAttendee.Type = olResource
 myItem.display
 myItem.send
 
 Set oOL = Nothing
End Sub
1689755836093.png
 
Last edited:

Gasman

Enthusiastic Amateur
Local time
Today, 06:52
Joined
Sep 21, 2011
Messages
14,299
Just for testing purposes, try the code I posted with a valid email address.
If that fails, try a repair of office.
 

Nous1970

New member
Local time
Today, 07:52
Joined
Feb 18, 2018
Messages
21
I figured out where I went wrong, and it was actually very simple :)
I only had to change the meeting status.
Code:
.MeetingStatus = olNonMeeting

to
Code:
.MeetingStatus = olMeeting

and everything worked perfect now :)

Thanks to your code, I noticed where I went wrong.

(y)(y)
 
Solution

Gasman

Enthusiastic Amateur
Local time
Today, 06:52
Joined
Sep 21, 2011
Messages
14,299
Not my code.
I copied that from that link I posted.
TBH I thought you had too as I saw very similar variables.
 

Users who are viewing this thread

Top Bottom