Trouble with URI parsing C#?

57 views Asked by At

I am trying to create a text field that can be typed in but also accepts a dialogue box selection, so that a Contact can be attached to an outlook task. I'm basically trying to recreate the outlook forms contact field using c# and WPF. By which I mean there is a contact button that opens a dialogue to select a contact. That contact is then shown in the text field and is interactable and shows the contact details.

I've had success with the ShowNamesDialougue taking the names selected and writing them to a TextBox.

I have tried to pass a hyperlink to a TextBox and a RichtextBox, learning that the TextBox doesn't support it and then getting stuck with parsing the URI of the ContactItem.

foreach (Outlook.Recipient recipient in snd.Recipients)
{
    Hyperlink hyperKontakt = new Hyperlink(new Run(recipient.Name));
    hyperKontakt.NavigateUri = new Uri(contactsFolder.FolderPath *contactname*);                                
    HLTextBox.CaretPosition.Paragraph.Inlines.Add(hyperKontakt);
}

contactsFolder

 Outlook.Folder contactsFolder = _currentTaskItem.Application.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts) as Outlook.Folder;           

The error is System.UriFormatException: 'Invalid URI: The hostname could not be parsed.'

The value is the Folderpath property of the oldefaultcontacts folder.

new Uri(contactsFolder.FolderPath);

It Looks Like This in the Debugger \\[email protected]\contacts. I've tried looking for a fully qualified path, but always have trouble with what exactly MAPI is and where it resides.

0

There are 0 answers