Question

NET developers. I am trying to replicate what I've written in Outlook VBA in VB.NET. I've written a function in VBA to extract recipients and save them into a string and this is done in a function. The below code is my attemp in VB.NET and it is not really working at the moment(SplitTarget array has unique ID and I'm testing this on the first element at the moment).

Could you tell me where I've gone wrong?

    Dim Recipients As String
    Dim Obj As Object
    Dim types() As String

    types = Split("MailItem,AppointmentItem,JournalItem,MeetingItem,TaskItem", ",")
    Select Case True
        ' these items have a Recipients collection
        Case UBound(Filter(types, TypeName(objNamespace.GetItemFromID(GlobalVariables.splitTarget(0))))) > -1
            Obj = objNamespace.GetItemFromID(GlobalVariables.splitTarget(0))
            GlobalVariables.recips = Obj.Recipients
        Case TypeName(objNamespace.GetItemFromID(GlobalVariables.splitTarget(0))) = "Recipients"
            GlobalVariables.recips = objNamespace.GetItemFromID(GlobalVariables.splitTarget(0))
    End Select

   For k = 1 To GlobalVariables.recips.Count
        If GlobalVariables.recips(k).ToString <> "Caseflow System" Then
            If Recipients = "" Then
                Recipients = GlobalVariables.recips(k).ToString
            Else
                Recipients = Recipients & ";" & GlobalVariables.recips(k).ToString
            End If
        End If
    Next

    MsgBox("Recipients are: " + Recipients)
Was it helpful?

Solution

Why are you calling Recipient.ToString() (which comes from .Net, not OOM) instead of using Recipient.Name/Address/etc. properties?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top