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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Lotus Notes

Status
Not open for further replies.

Zygor

Technical User
Apr 18, 2001
271
US
Below is some code I found and made some adjustments to. I would appreciate any thoughts to help me insert some bolded words into my e-mail text.

Declare Function SetForegroundWindow Lib "user32" (ByVal hWnd As Long) As Long
Declare Function ShowWindow& Lib "user32" (ByVal hWnd As Long, ByVal nCmdShow As Long)

Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long

Private Function CreateNotesSession&()
Const notesclass$ = "NOTES"
' "Neues Memo - Lotus Notes"
Const SW_SHOWMAXIMIZED = 3
Dim Lotus_Session As Object

Dim rc&
Dim lotusWindow&
Set Lotus_Session = CreateObject("Notes.NotesSession")

DoEvents
DoEvents
lotusWindow = FindWindow(notesclass, vbNullString)
If lotusWindow <> 0 Then
rc = ShowWindow(lotusWindow, SW_SHOWMAXIMIZED)
rc = SetForegroundWindow(lotusWindow)
CreateNotesSession& = True
Else
CreateNotesSession& = False
End If
End Function

Sub CreateMailandAttachFileAdr(Optional IsSubject As String = "", Optional SendToAdr As String, Optional CCToAdr As String, Optional BCCToAdr As String = "", Optional Attach1 As String = "")
On Error GoTo Err_Routine

Const EMBED_ATTACHMENT As Integer = 1454
Const EMBED_OBJECT As Integer = 1453
Const EMBED_OBJECTLINK As Integer = 1452

Dim s As Object ' use back end classes to obtain mail database name
Dim db As Object '
Dim Doc As Object ' front end document
Dim beDoc As Object ' back end document
Dim workspace As Object ' use front end classes to display to user
Dim bodypart As Object '
Dim strWording As String

Call CreateNotesSession&

Set s = CreateObject("Notes.Notessession") 'create notes session
Set db = s.GetDatabase("", "") 'set db to database not yet named
Call db.OPENMAIL ' set database to default mail database
Set beDoc = db.CreateDocument
Set bodypart = beDoc.CreateRichTextItem("Body")

' Filling the fields
'###################
beDoc.Subject = IsSubject
beDoc.SendTo = SendToAdr
beDoc.CopyTo = CCToAdr
beDoc.BlindCopyTo = BCCToAdr

' Attaches I
'###########
If Len(Attach1) > 0 Then
If Len(Dir(Attach1)) > 0 Then
Call bodypart.EmbedObject(EMBED_ATTACHMENT, "", Attach1, Dir(Attach1))
End If
End If

Set workspace = CreateObject("Notes.NotesUIWorkspace")


' Positioning Cursor
'###################
'Call workspace.EDITDOCUMENT(True, beDoc).GOTOFIELD("Body")

strWording = "Here is some text I want to add” ‘But I want the word ‘text’ to be bold

Call workspace.EDITDOCUMENT(True, beDoc).FIELDSETTEXT("Body", vbCrLf & strWording & vbCrLf & vbCrLf)

Set s = Nothing
Set db = Nothing
Set beDoc = Nothing
Set bodypart = Nothing
Exit Sub
Err_Routine:
Select Case Err.Number
Case 424
Resume Next
Case Else
MsgBox Err.Number & vbCrLf & Err.Description

End Select
End Sub
 
Can anyone suggest another forum I should ask this in? Any help would be appreciated.

Thanks!
 
Why don't you look into NotesRichTextItem and belonging classes instead?

Have a look into following classes (first):
NotesRichTextItem class
NotesRichTextStyle class

For further options look into these (should not be needed for the stated purpose...):
NotesRichTextDocLink class
NotesRichTextNavigator class
NotesRichTextParagraphStyle class
NotesRichTextRange class
NotesRichTextSection class
NotesRichTextTab class
NotesRichTextTable class

With the latest additions in RTItem classes there is a lot you can do with these, and most probably easier, quicker and more flexible using these classes. If you need to edit it before sending, you can open it AFTER storing (that is still one of the 'good' ones with RTItems). It is stated that there should be a way to avoid storing, but that one I never had any success with, so if I need to SEE the result I store, send and optionally delete afterwords...

Brgds,

TrooDOS
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top