Solved Adding a Meeting to Outlook (1 Viewer)

Eureka99

New member
Local time
Today, 03:45
Joined
Jun 29, 2020
Messages
26
Hi Guys,

I'm trying to add a button that will add a meeting to MS Outlook.

Most of the code I have been able to find / scratch together is working.

But i'm having issues with the "TO" command as this wasnt in any code I could find. Any ideas?

Code:
MRoom = DLookup("MeetingRoomEmail", "Tbl_MeetingRoom", "MeetingRoomID=" & Me.RoomID)
holonL = DLookup("HLEmail", "Tbl_HolonLeader", "HolonLeaderID=" & Me.HolonLID)
User = DLookup("Uemail", "Tbl_User", "UserID=" & Me.UserID)
HR = DLookup("HRemail", "Tbl_HR", "HRID=" & Me.HRID)
strInvitees = holonL & "," & User & "," & HR


Dim outApp As Object
    Dim outMail As Object
    Const olAppointmentItem = 1
    Set outApp = CreateObject("Outlook.Application")
    Set outMail = outApp.CreateItem(olAppointmentItem)
     outMail.To = strInvitees
    
          
        outMail.Subject = Me.MSubject
        outMail.Location = MRoom
        outMail.MeetingStatus = olMeeting
 outMail.Start = Me.MDate + Me.MStartTime
outMail.End = Me.MDate + Me.MStopTime
        outMail.ReminderMinutesBeforeStart = 30
        outMail.ReminderSet = True
    outMail.Display
    outMail.Send
    Set outMail = Nothing
    Set outApp = Nothing
 

Gasman

Enthusiastic Amateur
Local time
Today, 03:45
Joined
Sep 21, 2011
Messages
14,238
Aren' email addresses normally seperated by ; ?
 

Eureka99

New member
Local time
Today, 03:45
Joined
Jun 29, 2020
Messages
26
Yes they are.

However I have found the code that I was looking for to add receipients and now I have

Code:
MRoom = DLookup("MeetingRoomEmail", "Tbl_MeetingRoom", "MeetingRoomID=" & Me.RoomID)
holonL = DLookup("HLFirstname", "Tbl_HolonLeader", "HolonLeaderID=" & Me.HolonLID) & " " & DLookup("HLLastName", "Tbl_HolonLeader", "HolonLeaderID=" & Me.HolonLID)
User = DLookup("UFirstname", "Tbl_User", "UserID=" & Me.UserID) & " " & DLookup("ULastname", "Tbl_User", "UserID=" & Me.UserID)
HR = DLookup("HRFirstname", "Tbl_HR", "HRID=" & Me.HRID) & " " & DLookup("HRLastname", "Tbl_HR", "HRID=" & Me.HRID)



strInvitees = holonL & "; " & User & "; " & HR & ";"



Dim outApp As Object
    Dim outMail As Object
    Const olAppointmentItem = 1
    Set outApp = CreateObject("Outlook.Application")
    Set outMail = outApp.CreateItem(olAppointmentItem)
    outMail.Recipients.Add (strInvitees)
    
    
         outMail.Body = Me.Mdescription
        outMail.Subject = Me.MSubject
        outMail.Location = MRoom
        outMail.MeetingStatus = olMeeting
 outMail.Start = Me.MDate + Me.MStartTime
outMail.End = Me.MDate + Me.MStopTime
        outMail.ReminderMinutesBeforeStart = 30
        outMail.ReminderSet = True
    outMail.Display
    outMail.Send
    Set outMail = Nothing
    Set outApp = Nothing

The only annoying thing is that the names dont get recognised by t he company address book, so it doesnt send automatically
 

Gasman

Enthusiastic Amateur
Local time
Today, 03:45
Joined
Sep 21, 2011
Messages
14,238
I used the actual names as they were in my address book, and then resolved the names.
Code:
            For Each objOutlookRecip In .Recipients
                'Debug.Print objOutlookRecip.Name
                objOutlookRecip.Resolve
            Next
Otherwise, just use their raw email addresses?
 

Users who are viewing this thread

Top Bottom