Hello all,
I'm new at VBA and I have some difficulties automating some properties of outlook emails
The goal is to set importance from a table indicating High, Normal or Low priority and then in the code complete the missing part.
The property of the method is:
.Importance = olImportanceHigh
And what I want is to achieve is something like the code below but it keeps saying type mismatch
.Importance = "olImportance" & setupsht.Range("F" & I).Text
I've found a solution using nested ifs and converting "High" to 3 and "Normal" to 2 and so on, but this is not what I'm looking for.
I also have the same problem with BusyStatus...
Is there any idea how to solve this issue?
I attach you my code:
I'm new at VBA and I have some difficulties automating some properties of outlook emails
The goal is to set importance from a table indicating High, Normal or Low priority and then in the code complete the missing part.
The property of the method is:
.Importance = olImportanceHigh
And what I want is to achieve is something like the code below but it keeps saying type mismatch
.Importance = "olImportance" & setupsht.Range("F" & I).Text
I've found a solution using nested ifs and converting "High" to 3 and "Normal" to 2 and so on, but this is not what I'm looking for.
I also have the same problem with BusyStatus...
Is there any idea how to solve this issue?
I attach you my code:
VBA Code:
Sub SendInviteToMultiple()
Dim OutApp As Outlook.Application
Dim OutMeet As Outlook.AppointmentItem
Dim I As Long
Dim setupsht As Worksheet
Set setupsht = ActiveSheet
For I = 8 To Range("A" & Rows.Count).End(xlUp).Row
Set OutApp = Outlook.Application
Set OutMeet = OutApp.CreateItem(olAppointmentItem)
With OutMeet
.SendUsingAccount = OutApp.Session.Accounts(setupsht.Range("A" & I).Value)
' .SentOnBehalfOfName = "Sales@something.nl"
.Subject = setupsht.Range("B" & I).Value
.RequiredAttendees = setupsht.Range("C" & I).Value
.OptionalAttendees = setupsht.Range("D" & I).Value
.BusyStatus = "ol" & setupsht.Range("E" & I).Value ' this doesn't work. It says type mismatch
.Importance = "ol" & setupsht.Range("F" & I).Value ' this doesn't work. It says type mismatch
.Categories = setupsht.Range("G" & I).Value
If Not IsEmpty(setupsht.Range("H" & I).Value) Then
.Attachments.Add (setupsht.Range("H" & I).Value)
End If
.ReminderMinutesBeforeStart = setupsht.Range("I" & I).Value
.Start = setupsht.Range("J" & I).Text & " " & setupsht.Range("K" & I).Text
If setupsht.Range("L7").Value = "Duration" Then
.Duration = setupsht.Range("L" & I).Value
.Body = setupsht.Range("M" & I).Value
Else
.End = setupsht.Range("L" & I).Text & " " & setupsht.Range("M" & I).Text
.Body = setupsht.Range("N" & I).Value
End If
.MeetingStatus = olMeeting
.Display
End With
Next I
Set OutApp = Nothing
Set OutMeet = Nothing
End Sub