Lotusscript: Body Above Signature in Memo

I got a library of Lotusscript functions and code examples that I find useful and reuse in projects every now and then. Some are very simple and some did require a little or a lot of research and work before I got them working. In this post is an example on how to disable the email signature from Lotusscript.

Problem:
When creating a memo from backend Lotusscript and then showing it to the user using the frontend/UI classes, the user email signature (if enabled) will be inserted at the top of the document, i.e. the body text will be below the signature instead of above it as expected.

Solution:
Disable the signature and then re-enable it as shown in the following code example.

Limitations:
This is only an example on how to disable the user email signature. If you want it inserted at the end of whatever your email contents is (in this example “Hello world!”) you can easily modify the example to read the signature from docProfile and then insert it.

Pre-requisites:
This has been tested in Lotus Notes 6.5.3 but it should work both in previous releases such as R5 and in the later ND7 release.
Write a comment if you have confirmed this working (or not working) in other releases.

Below is a code example that
1) creates a memo using Lotusscript backend classes,
2) disables user email signature,
3) shows the memo to the user using Lotusscript frontend classes, and
4) re-enables the user email signature

Please note that the NotesRichTextItem Update method used in this example is new in ND6.


' ------------------------------------------------
' --- You may use and/or change this code freely
' --- provided you keep this message in your code
' ---
' --- Example by Max Flodén 2005
' --- http://www.tjitjing.com
' ------------------------------------------------

Dim workspace As New NotesUIWorkspace
Dim dbMail As NotesDatabase
Dim docMail As NotesDocument
Dim rtitem As NotesRichTextItem

Dim docProfile As NotesDocument
Dim strProfileEnableSignature As String

'Open users mail database
Set dbMail = New NotesDatabase( "", "" )
Call dbMail.OpenMail
If Not dbMail.IsOpen Then
Call Messagebox("Could not open mail database.", 48, "Error")
Exit Sub
End If

'Create new memo from back end
Set docMail = dbMail.CreateDocument
docMail.Form = "Memo"
docMail.Subject = "Hello"
Set rtitem = New NotesRichTextItem( docMail, "Body" )
Call rtitem.AppendText("Hello world!")
Call rtitem.AddNewline(1)
Call rtitem.Update 'Update method is new in ND6

'Disable signature in users mail profile
Set docProfile = dbMail.GetProfileDocument("CalendarProfile")
strProfileEnableSignature = docProfile.EnableSignature(0)
If strProfileEnableSignature = "1" Then
docProfile.EnableSignature = ""
Call docProfile.Save(True,False)
End If

'Show memo to UI/front end
Set uidoc = workspace.EditDocument(True, docMail,,,True,True)

'Re-enable signature in users mail profile
If strProfileEnableSignature = "1" Then
docProfile.EnableSignature = "1"
Call docProfile.Save(True,False)
End If

Ray Ozzie and Microsoft’s New Services Strategy

I just read this article in Fortune, headlined “Microsoft’s new brain”. It’s about Ray Ozzie but the real take aways for me were:

1) how Microsoft think about their new services strategy.

2) the report on how the new management at Microsoft work. I had understood that Ozzie played an important role but not that important.

Neither had I realized the vast amounts of money that needs to be put in to hardware and infrastructure investments. Some quotes:

“Just think about where there are windmills, dams, and other natural power sources around the world, and that’s where you’re going to see server farms,” he says.

“The people who could build a viable services infrastructure of scale,” he says, “are companies that have both the will and the capacity to invest staggering amounts of money – staggering amounts.” Think billions, many billions.

Google is rumored to have a million servers around the world and, according to a knowledgeable source, is already the top electricity user in at least one large U.S. state. Google would not comment.

Problem solved: FTP and Windows 2003 Firewall

Since I’m new to blogging I didn’t know how to use my own domain name with this blog. A quick Google revealed that the way it works is that I simply use Blogger as usual but whenever I publish anything it is published to my web server using FTP.

I have my own web server and currently do not use FTP so I had to set that up. I’m using Windows 2003 Server Enterprise Edition SP1 and I wanted to use the FTP server that comes with it (IIS 6). I have set up FTP on Windows before so I didn’t think it would be a problem, but that was before the Windows firewall…

After setting up configuring and starting my FTP server I had no problem to log on to it, but I got a timeout right away when the FTP client (I was simply using IE6 as my FTP client) tried to do the initial directory listing. Same thing when I tried to publish from Blogger. Using localhost on the server itself or using the console FTP client – ftp.exe – in Windows XP SP2 worked fine however.

I’ll skip all the Googling, MSDN search, trial and error and try to make a long story short:

I found out that there seems to be a problem with the Windows Firewall. On the Exceptions tab I had made an exception for FTP on TCP port 21 but as it turned out that did not work but I had to go to the Advanced tab, select my connection under Network Connection Settings and click the Settings button. From there check FTP Server and voìla, it works.

Why there is a difference between making the exception from the Exceptions tab or the Advanced tab I don’t know, probably a bug if you ask me. But right now I don’t care about that – I’m just happy that it’s working!

My return as a blogger…

Welcome to my blog!

This is my second attempt at blogging. My first attempt was a personal blog on things that are not work (ie technology) related. So I blogged on what happened to Rick Astley and things like that. After a total of three or four posts over almost a year my poor blog died from starvation…

Since then I have come to realize that what I would really like to blog about is the everyday things I come across related to my work and technology. I Google a lot everyday about things that interest me and to find solutions to problems. Sometimes I don’t find the answers or only find small bits of answers here and there. One of my intentions with this blog is to summarize or write about how I solved those kind of problems. Hopefully this will help someone else out.

Ok, let’s see how it works out. First of all I’m going to do a short post on how to get ftp to work behind the Windows firewall.

Welcome!

P.s. So what happened to Rick Astley? He’s still making records and touring but not as successfully as he used to… this is his homepage.