AppendText in an email (memo), but BEFORE the email footer

Hi,I am trying to send an email from my application, including a doclink.

Unfortunately, it appears @MailSend only allows 255 characters.

So I am using script to send the email.

Basically, it works, BUT the text and the document link are literally ‘appended’ to the email, e.g. at the end.

Most people in our company use email ‘signatures’. I want the Text and the doclink to appear BEFORE the signature, not AFTER the signature, that just looks silly and is inconvinient.

Heres the code:-

Sub Initialize

Dim memo As NotesDocument

Dim rtitem As NotesRichTextItem

Dim object As NotesEmbeddedObject

Dim ws As New NotesUIWorkspace

Dim MailServer As String

Dim MailFile As String

Dim MailDB As NotesDatabase

Dim ses As NotesSession

Dim g_thisDB As NotesDatabase

Dim tMsg As String

Dim tMsgTitle As String

Dim Doc As NotesDocument

Dim db As NotesDatabase





Set ses = New NotesSession

Set g_thisDB = ses.CurrentDatabase

Set db = ses.CurrentDatabase

'Get mail file information from Location document using Notes.ini

MailServer = ses.GetEnvironmentString( "MailServer",True)

MailFile = ses.GetEnvironmentString( "MailFile",True)



'Attempt to open local mail file

Set MailDB = New NotesDatabase("", MailFile)	

If Not MailDB.IsOpen Then

	'Attempt to open server replica of mail file

	Set MailDB = New NotesDatabase(MailServer, MailFile)	

	If Not MailDB.IsOpen Then

		Msgbox "An error occured opening your Mail File.",16, "Notice"

		Exit Sub

	End If

End If





'This new code should create an email in the users Mailbox

Set memo = MailDB.CreateDocument



' Note: If this sub is called by a server agent, the From field gets replaced by the ID that signed the agent

memo.Form = "Memo"

memo.From = ses.UserName

memo.SendTo = "Someone@SomeCompany.Com"

memo.CopyTo = ""

memo.BlindCopyTo = ""

memo.Subject = "3M Price Quote "

' can include code like this & doc.OurRef(0) on the above line to include things 

'from the document

'May need a little customisation to do this e.g. may need to Set doc

'reply.Subject = "Re: " & memo.Subject( 0 )



' Create the body field for the memo

Set rtitem = memo.CreateRichTextItem("Body")



'Call rtitem.AddNewLine(1)

Call rtitem.AppendText("Heres some example text, hard coded")

Dim uidoc As NotesUIDocument

Set uidoc = ws.CurrentDocument

Set Doc = uidoc.Document	



Call rtitem.AppendDocLink( doc, db.Title )

'Dim file As NotesRichTextItem

'Set file = doc.GetFirstItem( "QuoteAsAttachment" )

'Call rtitem.AppendRTItem(file) 



' Append file attachment rtf field to the body of the memo

'Call rtitem.AddNewLine(1)

'If (rtitem_lkup.Type <> ERRORITEM) Then  'Verify item is not an error

	'Call rtitem.AppendRTItem(rtitem_lkup)

'End If



'Open memo in the UI

Call memo.ComputeWithForm(True, False)

Call ws.EditDocument(True, memo)



'Send the memo - OLD - SENDS DIRECTLY!!

'Call memo.Send(False)

End Sub

Subject: RE: AppendText in an email (memo), but BEFORE the email footer

Andrew,

I was using pretty much the same methods that you were and also ran into the “signature at the top” problem. The way I solved it was a bit iffy, but it worked.

What I do is interrogate the user’s signature settings before creating the mail. If he has a signature enabled, I disable it and then copy the signature text to a string variable in LotusScript. (I don’t bother if it’s an HTML file signature).

Now I can build my rich text field as before, append the user’s signature to it myself, then create the mail and put it into Edit mode as before. (I don’t actually send it via code).

The last step, of course, is to re-enable the signature setting in his mail file if I disabled it previously.

Signature settings are held on the user’s CalendarProfile profile document by the way. The fields to check are EnableSignature, SignatureOption and Signature.

Cheers,

  • Mike

Subject: AppendText in an email (memo), but BEFORE the email footer

Sorry, I have no advice on your LS script, but I can offer this:

@MailSend does not have a 255 character limit. When it fails, it is often because a non-text data item was not or could not be converted to text. I have also recently caused it to fail by using LS-style ampersands as text operators instead of formula-style plus signs.

Good luck.

Subject: My Solution - AppendText in an email (memo), but BEFORE the email footer

Hi,

I recently posted some code that solves this problem at http://www.tjitjing.com/blog/2006/05/lotusscript-body-above-signature-in.html

hth