none
Outlook Add-in: How to add a hyperlink text to Subject line RRS feed

  • Question

  • Hi,

    I am novice to outlook add-in development.

    Problem Statement: I would like to embed a hyperlink in the subject line, programmatically. I tried something similar to the below

    Dim objMsg As Outlook.MailItem
    Dim objInBoxItems As Outlook.Items
    Dim strSubject as String
    
    objInBoxItems = objInBoxFolder.Items.Restrict("[UnRead] = false")
    objInBoxItems.GetFirst()
    If objInBoxItems.Count > 0 Then
      For Each eMail As Object In objInBoxItems
          objMsg = TryCast(eMail, Outlook.MailItem)
          If Not objMsg Is Nothing Then
              strSubject = "<a href=""" & "http://MyServer/MyApp/ShowDetails.aspx?id=" & intCount & """>Message Details</a>"
             objMsg.Subject = strSubject + objMsg.Subject
             objMsg.HTMLBody = "Details " + strSubject + objMsg.HTMLBody
          End If
       Each
    End If
    
    
    
     

    When this code is executed, the subject line changes to "<a href="http://MyServer/MyApp/ShowDetails.aspx?id=1">Message Details</a>" and it does not show a hyperlink under "Message Details text, which I was expecting.

    The Message body content appear correct, showing a hyperlink.

    I do not know how to get the hyperlink embedded into the subject line.

    Is it possible to add a hyperlink text in the subject line?

    Any help is greatly appreciated.

    Thanks

    Vinay


    VNB

    Monday, October 22, 2012 8:53 AM

Answers

  • Not possible, Subject doesn't support HTML rendering.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "VInay N. Barigidad" <=?utf-8?B?VkluYXkgTi4gQmFyaWdpZGFk?=> wrote in message news:c32b76a3-2d45-4cc6-b94d-110ec028f2e8...

    Hi,

    I am novice to outlook add-in development.

    Problem Statement: I would like to embed a hyperlink in the subject line, programmatically. I tried something similar to the below

    Dim objMsg As Outlook.MailItem
    Dim objInBoxItems As Outlook.Items
    Dim strSubject as String
    
    objInBoxItems = objInBoxFolder.Items.Restrict("[UnRead] = false")
    objInBoxItems.GetFirst()
    If objInBoxItems.Count > 0 Then
      For Each eMail As Object In objInBoxItems
          objMsg = TryCast(eMail, Outlook.MailItem)
          If Not objMsg Is Nothing Then
              strSubject = "<a href=""" & "http://MyServer/MyApp/ShowDetails.aspx?id=" & intCount & """>Message Details</a>"
             objMsg.Subject = strSubject + objMsg.Subject
             objMsg.HTMLBody = "Details " + strSubject + objMsg.HTMLBody
          End If
       Each
    End If
    
    
    
     

    When this code is executed, the subject line changes to "<a href="http://MyServer/MyApp/ShowDetails.aspx?id=1">Message Details</a>" and it does not show a hyperlink under "Message Details text, which I was expecting.

    The Message body content appear correct, showing a hyperlink.

    I do not know how to get the hyperlink embedded into the subject line.

    Is it possible to add a hyperlink text in the subject line?

    Any help is greatly appreciated.

    Thanks

    Vinay


    VNB


    Ken Slovak MVP - Outlook
    Monday, October 22, 2012 2:28 PM
    Moderator

All replies

  • Hi,

    I am novice to outlook add-in development.

    Problem Statement: I would like to embed a hyperlink in the subject line, programmatically. I tried something similar to the below

    Dim objMsg As Outlook.MailItem
    Dim objInBoxItems As Outlook.Items
    Dim strSubject as String
    
    objInBoxItems = objInBoxFolder.Items.Restrict("[UnRead] = false")
    objInBoxItems.GetFirst()
    If objInBoxItems.Count > 0 Then
      For Each eMail As Object In objInBoxItems
          objMsg = TryCast(eMail, Outlook.MailItem)
          If Not objMsg Is Nothing Then
              strSubject = "<a href=""" & "http://MyServer/MyApp/ShowDetails.aspx?id=" & intCount & """>Message Details</a>"
             objMsg.Subject = strSubject + objMsg.Subject
             objMsg.HTMLBody = "Details " + strSubject + objMsg.HTMLBody
          End If
       Each
    End If
    
    
    
     

    When this code is executed, the subject line changes to "<a href="http://MyServer/MyApp/ShowDetails.aspx?id=1">Message Details</a>" and it does not show a hyperlink under "Message Details text, which I was expecting.

    The Message body content appear correct, showing a hyperlink.

    I do not know how to get the hyperlink embedded into the subject line.

    Is it possible to add a hyperlink text in the subject line?

    Any help is greatly appreciated.

    Thanks

    Vinay


    VNB

    Monday, October 22, 2012 8:32 AM
  • Not possible, Subject doesn't support HTML rendering.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "VInay N. Barigidad" <=?utf-8?B?VkluYXkgTi4gQmFyaWdpZGFk?=> wrote in message news:c32b76a3-2d45-4cc6-b94d-110ec028f2e8...

    Hi,

    I am novice to outlook add-in development.

    Problem Statement: I would like to embed a hyperlink in the subject line, programmatically. I tried something similar to the below

    Dim objMsg As Outlook.MailItem
    Dim objInBoxItems As Outlook.Items
    Dim strSubject as String
    
    objInBoxItems = objInBoxFolder.Items.Restrict("[UnRead] = false")
    objInBoxItems.GetFirst()
    If objInBoxItems.Count > 0 Then
      For Each eMail As Object In objInBoxItems
          objMsg = TryCast(eMail, Outlook.MailItem)
          If Not objMsg Is Nothing Then
              strSubject = "<a href=""" & "http://MyServer/MyApp/ShowDetails.aspx?id=" & intCount & """>Message Details</a>"
             objMsg.Subject = strSubject + objMsg.Subject
             objMsg.HTMLBody = "Details " + strSubject + objMsg.HTMLBody
          End If
       Each
    End If
    
    
    
     

    When this code is executed, the subject line changes to "<a href="http://MyServer/MyApp/ShowDetails.aspx?id=1">Message Details</a>" and it does not show a hyperlink under "Message Details text, which I was expecting.

    The Message body content appear correct, showing a hyperlink.

    I do not know how to get the hyperlink embedded into the subject line.

    Is it possible to add a hyperlink text in the subject line?

    Any help is greatly appreciated.

    Thanks

    Vinay


    VNB


    Ken Slovak MVP - Outlook
    Monday, October 22, 2012 2:28 PM
    Moderator
  • Thanks Ken. This is helpful.

    I will think about workaround

    Regards

    Vinay


    VNB

    Friday, November 9, 2012 7:34 AM