How To Programmatically Embed a Hyperlink to a Message (263258)



The information in this article applies to:

  • Collaboration Data Objects (CDO) 1.2
  • Collaboration Data Objects (CDO) 1.21

This article was previously published under Q263258

SUMMARY

It may be necessary to send a message that contains a shortcut (or hyperlink) to a public folder or message. By clicking on the hyperlink, the recipient can easily reach the specified public folder or message. Note that to open items or files from a public folder, the recipient must have the appropriate permissions to the folder.

You can use Extended Messaging Application Programming Interface (MAPI) or the Microsoft Outlook Object Model to embed hyperlinks to messages. In the Outlook Object Model, you need to add the hyperlink as an attachment to the message. You also need to specify olEmbeddedItem(5) as the olAttachmentType constant.

CDO 1.2x does not directly support embedding hyperlinks to messages. With CDO 1.2x, you can only attach a copy of a message into another message, specifying the attachment type as CdoEmbeddedMessage. This article presents a limited workaround for that.

MORE INFORMATION

With CDO 1.2x, you can create a hyperlink to an Outlook folder or item by including a URL of type outlook:// within the body of a message. Because outlook:// is an Outlook-specific protocol, this method works only if the recipient views the messages by using an Outlook client.

You can use the outlook:// protocol in two different formats within the message text. The following examples assume that objMessage is a valid CDO 1.2x Message object that contains a hyperlink to a public folder message, objLinkedMessage:
' The following code displays the EntryID of objLinkedMessage in the URL.
' Because EntryID always uniquely identifies a message, this approach is safe to use.

objMessage.Text = "Please check out the following message." & vblf _
& "outlook:" & objLinkedMessage.ID


' The following code displays the subject of the message in the URL.
' You should use this only if you know that the subject of the message 
' would uniquely identify the objLinkedMessage under the folder "My Public Folder".

objMessage.Text = "Please check out the following message." & vblf _
& "<outlook://Public Folders/All Public Folders/My Public Folder/~" _
& objLinkedMessage.Subject & ">" 
				

REFERENCES

For additional information on using hyperlinks in Outlook, click the article number below to view the article in the Microsoft Knowledge Base:

225007 OL2000: Using Hyperlinks to Access Outlook Folders and Items


Modification Type:MinorLast Reviewed:7/2/2004
Keywords:kbhowto kbMsg kbOutlookObj KB263258