Custom script in mail template does not print output : version 9.1

I have HTML code in a file and read that file in a script CCC_Header() when i call that is mail template it does not print what was expected.

My script :

Imports System.IO


Public Function CCC_Header() As String
Dim Filepath As String= "C:/Header.html"
Dim Content As String = File.ReadAllText(Filepath)
Return Content
End Function

Call in mail Template:

$Script(CCC_Header):HTML$

Dear $FK(UID_PersonOrdered).FirstName$ $FK(UID_PersonOrdered).LastName$,

HTML code

"<style>
.container {
position: relative;
text-align: center;
color: Yellow;
}
.bottom-right {
position: absolute;
bottom: 8px;
right: 16px;
}
.centered {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
</style>
<body>
<div class="container">
<img src="c:/Clor.png" alt="Snow" style="width:100%;">
<div class="bottom-right"><h1 style="font-size:4em; "><a href="">https://example.com" style="text-decoration:none">IAM</a></h1></div>
<div class="centered"><h1 ><a href="">https://example.com" style="text-decoration:none">IAM</a><h1></div>
</div>
</body>

Output :

$Script(CCC_Header)$

Dear Rakesh

  • Please share the version of One Identity Manager you are using.

    Secondly, the scripts used in mail templates need to have follow a specific convention.

      Public Function CCC_HtmlMailText(obj As IEntity) As String
        Return $"<h1 style='color:red’>{obj.Display}</h1>"
      End Function

    and you need to provide the BaseObjectType attribute matching the base object type of your mail template. (Note: you can provide more than one attribute)

    You can find a sample in the OOTB script VI_BuildITShopLinks.

  • Hello Markus Thanks for quick response ,version was mentioned in Subject 9.1:)

    I do not need any base objects in my script as it is  header and footer html code with image and text on it with hyper link for all the custom mail templates so i referred the scripts used in signatures.  

    And Thanks i did modified the script and it worked 

    Current script

    <BaseObjectTypeAttribute("PwOHelperPwO"), _
    BaseObjectTypeAttribute("PersonWantsOrg")> _
    Public Function CCC_Header(ByVal Obj As ISingleDbObject) As String
    Dim Filepath As String= "C:/Header.html"
    Dim Content As String = File.ReadAllText(Filepath)
    Return Content.ToString()
    End Function

  • Ups ;-) My bad in regards to the version. And you are right, you do not need an entity as parameter.

    But I am just thinking, where did you test the mail template? Your code refers to C:/Header.html but this needs to be present.

    As debugging helper I would like you to include a different return value in your script and see if this value appears in your mail template.