Answers for "'Exception' is ambiguous, imported from the namespaces or types 'System, Microsoft.Office.Interop.Outlook'."

0

'Exception' is ambiguous, imported from the namespaces or types 'System, Microsoft.Office.Interop.Outlook'.

SUB AddAppointment()
		Dim OutlookApp As New Outlook.Application
    '--- Check if Outlook is already up and running
    If OutlookApp.GetProcessesByName("outlook").Count > 0 Then
        '--- all ready ---
    Else
        '--- start Outlook ---
        OutlookApp.Start("outlook")
        '--- more elaborate wait might be a good idea here ---
        System.Threading.Thread.Sleep(500)
    End If

    '--- initialize required Application object ---
    '--- assuming it is not available as variable already ---
    Dim objOutlook As Outlook.Application
    objOutlook = CreateObject("Outlook.Application")

    Dim newAppointment As Outlook.AppointmentItem =
        objOutlook.CreateItem(Outlook.OlItemType.olAppointmentItem)
    Try
        With newAppointment
            .Start = Date.Now.AddHours(2)
            .End = Date.Now.AddHours(3)
            .Location = "ConferenceRoom #2345"
            .Body = "We will discuss progress on the group project."
            .Subject = "Group Project"
            .AllDayEvent = False
            .Recipients.Add("Roger Harui")
            Dim sentTo As Outlook.Recipients = .Recipients
            Dim sentInvite As Outlook.Recipient
            sentInvite = sentTo.Add("Holly Holt")
            sentInvite.Type = Outlook.OlMeetingRecipientType.olRequired
            sentInvite = sentTo.Add("David Junca")
            sentInvite.Type = Outlook.OlMeetingRecipientType.olOptional
            sentTo.ResolveAll()
            .Save()
            .Display(True)
        End With
    Catch ex As Exception
      Dm.write("The following error occurred: " & ex.ToString())
    End Try
End Sub
Posted by: Guest on February-15-2021

Code answers related to "'Exception' is ambiguous, imported from the namespaces or types 'System, Microsoft.Office.Interop.Outlook'."

Browse Popular Code Answers by Language