Problem when i send a mail by using mail template, the inserted link in the bocdy field is not alive

Hi …

When ever a change is done in the profile I am sending a mail to the user with the changed detaisl + the content present in the mail template which is defined in the application.

Because these mail template can be defined, i treid to insert links in the Body field and i found that these links are not active when the user receives the mail.

Here is the code …

Class iMail

Private iMailServer As String

Private iMailFilepath As String

Private iPutInFolder As String

Private iDB As NotesDatabase

Private iDoc As NotesDocument

Private iCopyTo As NotesItem

Private iBlindCopyTo As NotesItem

’ -----------------------------------------------------------------------------------------------------------------------

Function setBody( bodyTxt As String )

iDoc.ReplaceItemValue “Body”, bodyTxt

End Function

’ ----------------------------------------------------------------------

Sub setSubject(subject As String)

iDoc.ReplaceItemValue “Subject”, subject

End Sub

’ ----------------------------------------------------------------------

Sub setPutInFolder( folderName As String)

'iDoc.PutInFolder folderName, True

iPutInFolder = folderName

End Sub

’ ---------------------------------------------------------------------

Sub new()

iMailServer = “”

iMailFilepath = “”

iPutInFolder = “”

'Set iSubject = Nothing

Set iDoc = Nothing

'Set iSendTo = Nothing

Set iCopyTo = Nothing

Set iBlindCopyTo = Nothing

'Set iBody = Nothing

End Sub

’ ----------------------------------------------------------------------

Function init(retMsg As String) As Integer

On Error Goto ErrHandler

Dim retVal As Integer

Set iDB = New NotesDatabase(iMailServer, iMailFilepath)

Set iDoc = iDB.CreateDocument

iDoc.Form = “Memo”

'Set iSubject = New NotesItem( iDoc, “Subject”, “” )

'Set iBody = New NotesRichTextItem( iDoc, “Body”)

'Set iSendTo = New NotesItem( iDoc, “SendTo”, “” )

'Set iCopyTo = New NotesItem( iDoc, “CopyTo”, “” )

'Set iBlindCopyTo = New NotesItem( iDoc, “BlindCopyTo”, “” )

retVal = True

NormalExit:

init = retVal

Exit Function

ErrHandler:

If Err <> 0 Then

retMsg = “Error line " & Erl & " - " & Error & " (init)”

End If

init= retVal

Exit Function

End Function

‘-----------------------------------------------------------------------Function SendAndSave(retMsg As String) As Integer

On Error Goto ErrHandler

Dim retVal As Integer

If Not send(retMsg) Then

retVal = False

Goto NormalExit

End If

If Not save(retMsg) Then

retVal = False

Goto NormalExit

End If

retVal = True

NormalExit:

SendAndSave = retVal

Exit Function

ErrHandler:

If Err <> 0 Then

retMsg = “Error line " & Erl & " - " & Error & " (SendAndSave)”

End If

SendAndSave= retVal

Exit Function

End Function

’ ---------------------------------------------------------------------

Function save(retMsg As String) As Integer

On Error Goto ErrHandler

Dim retVal As Integer

iDoc.Save True, False

If Not iPutInFolder = “” Then

iDoc.PutInFolder iPutInFolder, True

End If

iDoc.Save True, False

retVal = True

NormalExit:

save = retVal

Exit Function

ErrHandler:

If Err <> 0 Then

retMsg = “Error line " & Erl & " - " & Error & " (save)”

End If

save= retVal

Exit Function

End Function

‘-----------------------------------------------------------------------Function send(retMsg As String) As Integer

On Error Goto ErrHandler

Dim retVal As Integer

If iDoc Is Nothing Then

If Not init( retMsg) Then

retVal = False

Goto NormalExit

End If

End If

iDoc.Send False

retVal = True

NormalExit:

send = retVal

Exit Function

ErrHandler:

If Err <> 0 Then

retMsg = “Error line " & Erl & " - " & Error & " (send)”

End If

send= retVal

Exit Function

End Function

’ ---------------------------------------------------------------------

Function BuildRegNoRequestStatusMail(requestDoc As NotesDocument, templateKey As String, retMsg As String) As Integer

On Error Goto ErrHandler

Dim retVal As Integer

Dim session As New NotesSession

Dim setupDoc As NotesDocument

Dim mailTemplateDoc As NotesDocument

Dim mailPutInFolder As String

Dim regNo As String

Dim customerNo As String

Dim requestor As String

Dim travelManager As String

Dim subjectTxt As String

Dim bodyTxt As String

Dim bodyItem As NotesItem

Dim nName As NotesName

mailPutInFolder = setupDoc.GetItemValue( FLD_SYS_SETUP_DEPARTMENTMAIL_FOLDER )(0)

If requestDoc.Form(0) = FLD_REQUEST_FORM Then

regNo = requestDoc.GetItemValue(FLD_REQUEST_REGNO)(0)

customerNo = requestDoc.GetItemValue(FLD_REQUEST_CUSTOMERNO)(0)

Set nName = New NotesName( requestDoc.GetItemValue( FLD_REQUEST_REQUESTOR )(0) )

requestor = nName.Common

End If

Set nName = New NotesName( session.UserName )

travelManager = nName.Common

subjectTxt = mailTemplateDoc.GetItemValue( FLD_MAILTEMPLATE_SUBJECT )(0)

subjectTxt = NFReplaceSubstring( subjectTxt, MAIL_TEMPLATE_DATATXT_REGNO, regNo)

bodyTxt = mailTemplateDoc.GetItemValue( FLD_MAILTEMPLATE_BODY )(0)

bodyTxt = NFReplaceSubstring( bodyTxt, MAIL_TEMPLATE_DATATXT_REGNO, regNo)

If Not init(retMsg) Then

retVal = False

Goto NormalExit

End If

Me.setReplyTo setupDoc.GetItemValue( FLD_SYS_SETUP_DEPARTMENTMAIL_EMAIL )(0)

Me.setPrincipal setupDoc.GetItemValue( FLD_SYS_SETUP_DEPARTMENTMAIL_EMAIL )(0)

Me.setSendTo requestor

Me.setSubject subjectTxt

Me.setBody bodyTxt

Me.setPutInFolder mailPutInFolder

retVal = True

NormalExit:

BuildRegNoRequestStatusMail = retVal

Exit Function

ErrHandler:

If Err <> 0 Then

retMsg = “Error line " & Erl & " - " & Error & " (BuildRegNoRequestStatusMail)”

End If

BuildRegNoRequestStatusMail= retVal

Exit Function

End Function

End Class

'----------------

Please tell me where i am doing wrong… the body field is ‘Rich Text’ but still the links are not active

Subject: Problem when i send a mail by using mail template, the inserted link in the bocdy field is not alive

try this

Set rtitem = New NotesRichTextItem( iDoc, “Body” )

Call rtitem.AppendStyle(session.CreateRichTextStyle)

Call rtitem.AppendText( “http://www.amazon.com” )

Subject: RE: Problem when i send a mail by using mail template, the inserted link in the bocdy field is not alive

Hello Paul…

Thanks alot for the response…

I am new bie in lotus notes …

I have added the above mentioned line in the funtion BuildRegNoRequestStatusMail…

Set rtitem = New NotesRichTextItem( iDoc, “Body” )

I got a error saying “Error creating Product object(Approve Request)”

I tried changing iDoc to requestDoc and mailtemplateDoc it doesnt have any effect …

Apart from adding the above line … do i have to make any changes in the code …???

Please help me … I am struggling with this … alot …