Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Lotus Notes Body Text/ Email VB

Status
Not open for further replies.

MattSTech

Programmer
Apr 10, 2003
333
0
0
US
Hello All,
After some digging I have come to the conclusion I yet again need assistance. I have a vb app that generates an email using the lotus notes object. I am attempting to write multiple lines to the body of the text with no avail. I have tried VBCrLf. Tried VBNewLine. Tried Chr(13) & Chr(10)(Which I believe to be the same as VBCrLf). No luck, still creates 1 long string with square boxes between the lines. Like I mentioned, I have searched on this forum and cannot find the solution, however, it was here where I found the code to connect to Lotus in the first place (Thank you all for those threads). Any help will be appreciated.

Matt

(Code)


Dim lotSession As Domino.NotesSession
Dim lotDocument As Domino.NotesDocument
Dim lotDatabase As Domino.NotesDatabase
Dim vRecipients As Variant

Set lotSession = New Domino.NotesSession

With lotSession
.Initialize "mypassword"
End With

Set lotDatabase = _
lotSession.GetDbDirectory("xxx").OpenMailDatabase

With lotDatabase
If Not .IsOpen Then
.Open
End If
End With

vRecipients = Array(strMail) 'To

Set lotDocument = lotDatabase.CreateDocument()

With lotDocument
.AppendItemValue "Form", "Memo"
.AppendItemValue "Subject", "This is a test"
.AppendItemValue "Body", & _
"This is the two Line Issue" & VBCrLf & _
"This text Should appear below the prior, but doesn't"

.Send False, vRecipients
Call .Save(True, False)'Save to Sent
End With

Set lotDocument = Nothing
Set lotDatabase = Nothing
Set lotSession = Nothing
 
Thanks for the reponse. I was attempting to get an answer for this question through the VB forum because I am primarily using VB, the Notes portion is just a tiny sub routine. I have seen several threads about formatting the body of an email in this forum and none has a solution. I have searched for some time as I respect this forum, and don't want to waste people's time, but I would like to close this issue for the other guys who are struggling.

I thank you for your response and will search the notes forum. If I find the answer I will post it here and attempt a FAQ on the bits of code I have found in the other threads.
 
MattSTech,

I'd be really interested to hear the solution if you find one. I host the Approach forum at and the exact same question came up a couple of days ago from somebody who's automating Notes from Approach. We suggested Chr$(13) & Chr$(10) but like you, it didn't work!

Paul Bent
Northwind IT Systems
 
One other thought (long shot). Does it create a HTML e-mail? If so I wonder if it expects the HTML formatted characters for a carriage return/line feed pair. They are:

%0D%0A

Paul Bent
Northwind IT Systems
 
Here seems to be a temporary fix. It doesn't seem to be well liked in the lotus forum you pointed me to, but it gets the job done for now. I will continue the search for a better solution and let you know.

Thanks very much for the help, it is greatly appreciated.

Matt

(Code)
'Place dim in proper position in above code

Dim rt as object

'Replace the <.AppendItemValue &quot;Body&quot;, > with

Set rt = .CreateRichTextItem(&quot;Body&quot;)
Call rt.AppendText(&quot;Line1&quot;)
Call rt.AddNewLine(1)
Call rt.AppendText(&quot;Line2&quot;)
 
You can also use the vbcrlf within the statement

Call rt.AppendText(&quot;Line1&quot; & vbcrlf & &quot;Line2&quot;)

 
I recently found & used some code I used successfully in VBA. In place of the VBCrLf, it used |.

Hope this helps,

Beth L
 
I ran into this when sending an email to multiple recipients. You can use an array

dim arrMsg(4) as string 'dimension it to the number of lines

arrMsg(0)="message line 1"
arrMsg(1)="message line 2" and so on

.AppendItemValue "Body", arrMsg()

It should work.
 
This should sort out your problem


Sub DoLotusEmail(strTo As String, strCC As String, strBCC As String, strSubject As String, Message As String, Attachments() As String)

'Display email in Notes prefilled with Subject, Message and Attachments
'Allow user to make edits (eg. to message) and then send manually

Const EMBED_ATTACHMENT As Integer = 1454
Const notesclass = "NOTES"
Const SW_SHOWMAXIMIZED = 3
'
Dim i&, t&, lotusWindow&

On Error GoTo LotusNotesFail

10: t = Timer
Screen.MousePointer = vbHourglass
Do Until lotusWindow <> 0 Or Timer - t > 5
lotusWindow = FindWindow("NOTES", vbNullString)
DoEvents
Loop
Screen.MousePointer = vbDefault

If lotusWindow = 0 Then
MsgBox "Lotus Notes must be running before you use this facility" & vbCrLf & _
" Please click ok and then try again", vbExclamation
Else
20: ShowWindow lotusWindow, SW_SHOWMAXIMIZED
30: SetForegroundWindow lotusWindow

'Set up the objects required for Automation into lotus notes
Dim Maildb As Object 'The mail database
Dim UserName As String 'The current users notes name
Dim MailDbName As String 'THe current users notes mail database name
Dim MailDoc As Object 'The mail document itself
Dim intAttach As Integer
Dim Session As Object 'The notes session
Dim EmbedObj As Object 'The embedded object (Attachment)
Dim Server As String

On Error GoTo LotusNotesFail

'Start a session to notes
Set Session = CreateObject("Notes.Notessession")

Set Maildb = Session.GetDatabase("", "")
Maildb.OPENMAIL
'Set up the new mail document

Set MailDoc = Maildb.CreateDocument

With MailDoc
.Form = "Memo"
.SendTo = strTo
.EnterCopyTo = strCC
.EnterBlindCopyTo = strBCC
.Subject = strSubject
.SaveMessageOnSend = True

Dim ric As Object
Set ric = .CreateRichTextItem("Body")
ric.AppendText Message & Chr$(13)
For intAttach = LBound(Attachments) To UBound(Attachments)
If Len(Attachments(intAttach)) <> 0 Then
Set EmbedObj = ric.EmbedObject(1454, "", Attachments(intAttach), "Attach")
End If
Next intAttach
.Save False, False
End With

DoEvents
Dim ws As Object
Set ws = CreateObject("notes.notesuiworkspace")
DoEvents
ws.OpenDatabase Server, MailDbName
ws.EDITDOCUMENT True, MailDoc

'Clean Up
Set Maildb = Nothing
Set MailDoc = Nothing
Set ric = Nothing
Set ws = Nothing
Set Session = Nothing
Set EmbedObj = Nothing
End If
Exit Sub

LotusNotesFail:
MsgBox ("Cannot open new memo in Lotus Notes. Please make sure you have Lotus Notes running in your computer.")


End Sub
 
wiglaer,

Shades of thread222-1005915, hope you have it sussed, big star deferred until tested <g>

kind regards Hugh

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top