score:0

resolve does nothing when you use an email address.

use display name / other name property in createrecipient if you want to follow up with a useful if myrecipient.resolved then.


option explicit

sub resolvename()
    ' déclaration des variables
    dim outlookapp as outlook.application
    dim mynamespace as outlook.namespace
    dim myrecipient as outlook.recipient
    dim calendarfolder as outlook.folder
    dim calendarapp as outlook.appointmentitem
    dim calendaritem as outlook.items
    dim i as long

    set outlookapp = new outlook.application
    set mynamespace = outlookapp.getnamespace("mapi")
    set myrecipient = mynamespace.createrecipient("nothingvalid@hydro.qc.ca")
    i = 2

    myrecipient.resolve
    'range("a1:d1").value = array("subject", "from", "date", "location")
    if myrecipient.resolved then
        debug.print "anything that looks like an email address will resolve."
        debug.print "use display name / other name property."
        'set calendarfolder = mynamespace.getshareddefaultfolder(myrecipient, olfoldercalendar)
        'for each calendarapp in calendarfolder.items
        '    cells(i, 1).value = calendaritem.subject
        '    cells(i, 2).value = calendaritem.start
        '    cells(i, 3).value = calendaritem.end
        '    cells(i, 4).value = calendaritem.location
        '    cells(i, 5).value = calendaritem.meetingstatus
        '    i = i + 1
       ' next
    end if

    set outlookapp = nothing
    set mynamespace = nothing
    set myrecipient = nothing
    set calendarfolder = nothing
    set calendaritem = nothing
end sub

Related Query

More Query from same tag