How do I... (email text alignment question)

I am developing a new version of an existing Notes client application wherein users can create a communication to an outside client. The communication can go out in email or hard copy, and can be in any of several languages. The recipients are outside so there’s no way to know what they are using to read it.

The application is written such that the entire text of the email/letter is created by a script, that is, as plain text.

One unforseen problem has come up: Our Japanese liason says the closing (in English, “Sincerely,” followed by the sender’s name) should be right-aligned. Is it possible to right align this part while still sending as plain text?

Is sending as HTML MIME (not sure of the terminology here) the only answer? And if I go that route is there anything I should watch out for?

Many thanks.

Subject: How do I… (email text alignment question)

Hey Thomas -

You might be able to use Rset to do it.

Const BUFF_SZ = 8 * 4

Dim strBuff As String * BUFF_SZ



strBuff$ = Space(BUFF_SZ)

Rset strBuff$ = "Sincerely" '// right justify string into the buffer

Msgbox strBuff$, , "DEBUG . . ."

You’d need to add the text to the body after justifying it or risk losing the alignment in the string.

hth,

dgg

Subject: How do I… (email text alignment question)

Yep… Plain text means no format.

You’ll have to use MIME

Things to check.

On Notes Client:

File - Preferences - User Preference

Mail (left nav) - Internet (sub of mail)

Internet Mail Format: HTML Only or HTML and Plain Text

In your location document (located in names.nsf(local)), on the Mail (tag)

Format for messages address to Internet addresses: MIME Format

  1. In creating email: View - Show - Pass-Thru HTML.

Check if sent in MIME by looking a few fields have been added such as they have MIME in the field name. ($NoteHasNativeMIME, MIME_Version, etc…)


With the script.

------ LOTUS’s CORRECT WAY OF DOING IT --------

'Dim currentdoc As NotesDocument

'Dim session As New NotesSession

Dim rtstyle As NotesRichTextStyle

Dim rtpstyle As NotesrichTextParagraphStyle

Set rtitem = currentdoc.GetFirstItem(“Body”)

Set rtstyle = session.CreateRichTextStyle

Set rtpStyle = session.CreateRichTextParagraphStyle

With rtstyle

.NotesFont = rtitem.GetNotesFont(“Arial”, True)

.FontSize = 10

.NotesColor = COLOR_BLACK

.Bold = False

End With

’ Add all your previous script here.

Call rtitem.AppendStyle(rtstyle)

rtitem.Appendtext(Chr(10))

’ ALIGN_RIGHT = 1

rtpStyle.Alignment = ALIGN_RIGHT

Call richText.AppendParagraphStyle(rtpStyle)

rtitem.Appendtext(“Yours sincerely,” + Chr(10) + Chr(10))

rtirem.Appendtext(session.CommonUserName + Chr(10))

’ ALIGN_LEFT = 0

rtpStyle.Alignment = ALIGN_LEFT

Call richText.AppendParagraphStyle(rtpStyle)

--------END CORRECT WAY -------------------------

------- ANOTHER CHEATS WAY ----------------------

’ Reasoning behind the cheats way is that Notes Styles are sometimes a headache.

’ They don’t always format correctly. :frowning: and also too long in their code.

’ source = NotesUIDocument

temp$ = Environ(“Temp”)

fileNum% = Freefile()

fileName$ = temp$ + “\signature.html”

Open fileName$ For Output As fileNum%

’ Add HTML code here

Print #fileNum%, “”

Print #fileNum%, “<span style=”“font-family: text-align: right; helvetica,arial,sans-serif; font-size: 13px;”“>

”

Print #fileNum%, “Your Sincerely,
”

Print #fileNum%, session.CommonUsername + “

”

Close fileNum%

Call source.Import (“HTML File”, fileName$)

Kill fileName$

------ END CHEATS WAY --------------------------

If you have to use plain text then you can fudge it with adding a line of spaces i.e

'Text$ can be assign to the line of text

text$ = “Your Sincerely,”

RightMargin = 72

newtextline = Left(Space(RightMargin), RightMargin - Len(text$)) + text$

This method can cause a problem if recipient sets plain text font as a variable text i.e Arial spacing is not the same with each character. It would look messy.

I hope I’ve helped in some way or given you a point in the right direction.

Subject: RE: How do I… (email text alignment question)

That’s great, thank you.

I wuld really like to preview the email on-screen. Right now, because the email/hard copy is all text and is created by a script and not via a form ,the user can click on a Preview checkbox to see what the result will look like, without leaving the document or saving it etc. (They might do this, for example, to make sure they have selected the right address format for the recipient.) Is that no-save/no-exit preview going to be possible if I use mime?