Hi,
I am trying to create a send function within VB6 which can be called from a third party product. Below is the main commands from the v function I have created. The problem being is that it crashes out on the command L_RTITEM.AppendText (P_BODY) P_body contains the body of the email. I am wanting to add this text to the body of the email, is this the correct method to achieve this?
Public Function Send(ByVal P_SENDTO As String, ByVal P_CC As String, ByVal P_BCC As String, ByVal P_SUBJECT As String, ByVal P_BODY As String, ByVal P_ATTACHMENTS, ByVal P_IMPORTANCE As String, ByVal P_READ As String, ByVal P_DELIVER As String, ByVal P_ENCRYPT) As String
Dim L_RTITEM As NotesRichTextItem
'Create a blank document for this email
Set V_DOCUMENT = V_DATABASE.CreateDocument
Set L_RTITEM = V_DOCUMENT.CreateRichTextItem(“Body”)
L_RTITEM.AppendText (P_BODY)
Thanks in advance.
Subject: Send
Amber,
Been a while since I sent mail in VB6 so hopefully someone like Stan will straighten us out here…
Run it in debug – is L_RTITEM being set??? Do you have Early Binding enabled?
Also, your SendTo, CC and BCC fields should be vbVariants to handle arrays unless you know, without a shadow of a doubt, that they will contain no more than one name each. Otherwise, multiple values will be concatenated into a single value in a given “field” and the addresses will not resolve correctly.
I usually used to dim my Notes Objects as Objects (Late Binding) like this – not saying it’s the best or most correct way – depends on your situation:
Private Sub Command1_Click()
Dim session As Object
Dim db As Object
Dim doc As Object
Dim rtitem As Object
Set session = CreateObject( “Notes.NotesSession” )
Set db = session.GetDatabase( “”, “mail\groberts.nsf” )
Set doc = db.CreateDocument
doc.Form = “Memo”
doc.Subject = “Test Mail from Visual Basic”
Set rtitem = doc.CreateRichTextItem( “Body” )
Call rtitem.AppendText( “http://www.IBM.com” )
Call rtitem.AddNewLine(3)
Call rtItem.EmbedObject(EMBED_ATTACHMENT, “”, “c:\dir.txt”)
doc.SendTo = “groberts@whatever.com”
Call doc.Send( False )
Set session = Nothing
Set db = Nothing
Set doc = Nothing
End Sub