Recently I'm in the process to send mail from VFP(Ver6) to Lotus Notes(Ver6.5) and as a result I'm using
OleClass = "richtext.richtextctrl.1"
and store value TextRTF in memo field whatvalue in Cursor Temp. Now to do LotusNotes automation I stated below code:-
Local Maildb, MailDoc,Body, Session, lcBody, Server,MaildbName, attached, Stream, RichTextItem, BodyMime
Select Temp
go top
lcBody=Temp.whatvalue
attached=LOCFILE('', 'DOC', 'Select File')
* Start a session to notes
Session = CreateObject("Lotus.NotesSession")
*This line prompts for password of current ID noted in Notes.INI
Session.Initialize()
Session.ConvertMime=.F. && Read-write. &&
&& Indicates whether items of type MIME_PART &&
&& are converted to rich text upon NotesItem instantiation. &&
*Open the mail database in notes
Server = Session.GetEnvironmentString( "MailServer",.T.)
MaildbName = Session.GetEnvironmentString( "MailFile",.T.)
* open the notes mail database
Maildb = Session.getdatabase(Server, MaildbName )
*Create the mail document
MailDoc = Maildb.CREATEDOCUMENT
MailDoc.ReplaceItemValue("Form", "Memo")
*Set the receipient
MailDoc.ReplaceItemValue("SendTo", [email protected])
*Set subject
MailDoc.ReplaceItemValue("Subject", "Subject Text")
*Create and set the Body content
*Body = MailDoc.CREATERICHTEXTITEM("Body") && for Plain Text setting
*Body.APPENDText( Allt(lcbody) ) && not using due to RTF String
***MIME Entry
Stream=Session.CreateStream() && Create a Notes Stream Object,
Stream.WriteText(lcbody) && Write text into the Stream
BodyMIME = MailDoc.CreateMIMEEntity()
BodyMIME.SetContentFromText( Stream,"Text/RTF;charset=UTF-8", .F. )
*Session.ConvertMime=.T. && True indicates that MIME items are converted to rich text. &&
&& False indicates that MIME items are not converted.If use html,replace "Text/RTF" with "text/html" &&
** Attachment
RichTextItem = MailDoc.CreateRichTextItem("Attachment")
if !Empty(attached)=.T.
RichTextItem.EmbedObject(1454, "", attached,"Attachment" )
Endif
*Example to create an attachment (optional) for plain Text
*Body.ADDNEWLINE(2)
*Body.EMBEDOBJECT(1454, "", attached, "Attachment")
Maildoc.ReplaceItemValue( "Logo", "StdNotesLtr3" )
Maildoc.ReplaceItemValue( "_ViewIcon", 23 )
Maildoc.ReplaceItemValue( "SenderTag", "Y" )
Session.ConvertMime=.T.
*Example to save the message (optional)
MailDoc.SAVEMESSAGEONSEND = .T.
*Send the document
*Gets the mail to appear in the Sent items folder
MailDoc.ReplaceItemValue("PostedDate", DateTime())
MailDoc.SEND( .F. )
In view of above, my notes programme body of the mail is not convert RTF character to appropiate format(!).it is appearing something like this : {\rtf1\ansi\deff0{\fonttbl{\f0\fnil\fcharset0 Arial;}}
{\colortbl ;\red255\green0\blue0;}
\viewkind4\uc1\pard\cf1\lang1033\ul\b\i\fs18 TXTMAILBODY\cf0\ulnone\b0\i0
\par }
Will you please describe what am I missing here.?
With Regards