How to paste lotus notes link into outlook email

These days many companies switching from lotus notes to Outlook and so we get frequently need to paste notes link into outlook email. In this article I’ll be explaining how to create custom button which can paste lotus notes link into outlook email.

You can download vba project VbaProject. Extract VbaProject.OTM at C:\Users\<User>\AppData\Roaming\Microsoft\Outlook or alternatively follow below steps to create the vba project.

Open outlook and hit Alt+F11. This will open vba developer window. Create a new module and add below code:

Sub New_Paste_Link()

    Dim strLink As String
    Dim doLink As DataObject
    Dim strLinkName As String
    Dim intStart As Long

    Set doLink = New DataObject
    doLink.GetFromClipboard
    'MsgBox prompt:=doLink.GetText
    
    strLink = Parse_Link(doLink.GetText)

    If InStr(1, doLink.GetText, "<NDL>") > 1 Then
    
        intStart = InStr(1, doLink.GetText, vbCrLf)
        If intStart > 1 Then
            
            strLinkName = Left(doLink.GetText, intStart - 1)
        
        Else
            
            strLinkName = "Link"
        
        End If
    
    Else
    
        strLinkName = "Link"
    
    End If

    strLinkName = Trim(strLinkName)

    If strLink > "" Then
    
        With ActiveWindow.WordEditor.Application
    
            .ActiveDocument.Hyperlinks.Add Anchor:=.Selection.Range, Address:= _
            strLink, _
            SubAddress:="", ScreenTip:="", TextToDisplay:="Link"
    
        End With
        
    
    End If

End Sub

Function Parse_Link(strDetails As String) As String

    Dim intStart As Long
    Dim strServer As String
    Dim strPart1 As String
    Dim strPart2 As String
    Dim strPart3 As String
    Dim strPart4 As String
    Dim strPart5 As String
    Dim strPart6 As String
    Dim strLinkName As String
    Dim strNewLink As String
    

    If Left(strDetails, 8) = "Notes://" Then
    
        Parse_Link = strDetails
        Exit Function
    
    Else
               
        
        intStart = InStr(1, strDetails, "<HINT>CN=", vbTextCompare)
        If intStart > 1 Then
        
            'AXLAMB 6/27/2011 - BEGIN
            'Updated server, per suggestion from Barry Littner, to use the generic server rather than explicit server
            
            'strServer = Mid(strDetails, intStart + 9, 7)
            strServer = "anyserver"
            
            'AXLAMB 6/27/2011 - END
                    
        Else
            If Left(strDetails, 8) = "https://" Or Left(strDetails, 7) = "http://" Then
    
                Parse_Link = strDetails
                Exit Function
            
            Else
            
                MsgBox prompt:="Unable to identify link " + strDetails
                Parse_Link = ""
                Exit Function
            End If
        
        End If
        
        intStart = InStr(1, strDetails, "<REPLICA ", vbTextCompare)
        strPart1 = Mid(strDetails, intStart + 9, 8)
        strPart2 = Mid(strDetails, intStart + 18, 8)
    
        intStart = InStr(1, strDetails, "<VIEW OF", vbTextCompare)
        If intStart > 0 Then
            strPart3 = Mid(strDetails, intStart + 8, 17)
            strPart4 = Mid(strDetails, intStart + 28, 17)
        Else
            strPart3 = ""
            strPart4 = ""
        End If
        
        intStart = InStr(1, strDetails, "<NOTE OF", vbTextCompare)
        If intStart > 0 Then
            strPart5 = Mid(strDetails, intStart + 8, 17)
            strPart6 = Mid(strDetails, intStart + 28, 17)
        Else
            strPart5 = ""
            strPart6 = ""
        End If
        
        'MsgBox prompt:=strPart1 & vbCrLf & strPart2 & vbCrLf & strPart3 & vbCrLf & strPart4 & vbCrLf & strPart5 & vbCrLf & strPart6
        
        'Check if this is a link for a specific document or a database.  You can tell the difference if the additional references are missing
        If strPart3 > "" Then
        
            strNewLink = strServer & "/" & strPart1 & strPart2 & "/" & strPart3 & strPart4 & "/" & strPart5 & strPart6
    
        Else
        
            strNewLink = strServer & "/" & strPart1 & strPart2
        
        End If
    
        strNewLink = Trim("Notes://" & Replace(strNewLink, ":", ""))
    
        'MsgBox prompt:=strNewLink
        
        Parse_Link = strNewLink
    
    End If


End Function

Save the project.

  1. Create new email and open File –> Options
  2. Add new button in ribbon and select Macro From drop down and add.
  3. This will add a new button in ribbon
  4. Now we need enable the macro for that follow below steps in Outlook 2010. In other version you may find similar options with little variation

Step 1: Click the File > Options.

Step 2: In the Outlook Options dialog box, click the Trust Center in the left bar.

Step 3: Click the Trust Center Settings button.

Step 4: In the Trust Center dialog box, click the Macro Settings in the left bar.

Step 5: In the Macro Settings section:

To enable all macros, please check the Enable all macros (not recommended; potentially dangerous code can run) option.

To disable all macros in your Microsoft Outlook, please uncheck the Enable all macros (not recommended; potentially dangerous code can run) option.

Step 6: Click OK buttons in each dialog box.

Step 7: Restart your Microsoft Outlook to activate it.

5. Now new button at ribbon is ready to use.
6. In Lotus Notes, open the document, view, or application you want to link to.
7. Click Edit > Copy as Link, then select Document Link, View Link, or Application Link.
8. In new email window point the cursor where you need to paste the link and use new button at ribbon.
9. This add a new hyperlink pointing to the notes document.

This macro is smart enough to handle normal http/https links as well.

Please share your feedback.

 

9 thoughts on “How to paste lotus notes link into outlook email

  1. Uwe G. says:

    Get a debug error “User-defined type not defined” at
    Dim doLink As DataObject

    1. Uwe G. says:

      Does not work with Outlook 2016 (VBA 7.1)

      1. Ourhints says:

        I am using it with 2010. Not sure about other versions.

  2. Uwe G. says:

    Got it working in Outlook 2016 now. The issue was a missing reference to c:\Windows\SysWOW64\FM20.dll which needs to be added under Tools ==> References via Browse … in Microsoft Visual Basic. https://answers.microsoft.com/en-us/msoffice/forum/msoffice_word-mso_win10-mso_2016/mystery-compile-error-user-defined-type-not/b0c07a65-9f0c-43f1-a181-12c95db0ac8d?auth=1&rtAction=1528874415704

    1. Ourhints says:

      Thanks for posting your solution. Really appreciate that.

  3. playhome dlc says:

    Hello! I just wanted to ask if you ever have any trouble with hackers? My last blog (wordpress) was hacked and I ended up losing a few months of hard work due to no backup. Do you have any methods to prevent hackers?

  4. Mazie Leemow says:

    thanks for sharing this information have shared this link with others keep posting such information..

  5. Uwe G. says:

    For IBM Notes 9 Social Edition (used on Windows 10) you get the script working if you do a little change in line 72 where you need to replace “CN=” by ” ” (replace CN= by two spaces)

  6. Hardy says:

    This is awsome. Thank you.

Leave a Reply

Your email address will not be published. Required fields are marked *