Append Body?

Hello fellow peeps, My code below works…it grabs the rich text from a document and puts it into the body of an email I am sending out automatically via a specified view…because this view has all the email addy’s in it that I want.

But…what is also stored in this view that has email addy’s are some codes that I need to send out with the email as well. I have been trying all sorts of append item and append rich text, but run into some class issues.

I’m a little we behind the ears when it comes to LS, but i’m learning…well, I did the below code!

Now I just need to grab the codes from the docs and put them into the separate emails and i’ll be good.

Any ideas? I’m searching and trying things and will post back if I fix.

Thank you so much in advance!

P.S. the Profile2 view is the view that stores the email addy’s and the codes. 1 form with 2 fields on it.

start code here

Sub Initialize

Dim session As New NotesSession

Dim db As NotesDatabase

Dim db2 As NotesDatabase

Dim view As NotesView

Dim doc As NotesDocument



Dim itemA As NotesItem



Set db = session.CurrentDatabase

Set db2 = New NotesDatabase( "<servername here>", "<maildb>.nsf" )

Set view = db.GetView("Profile2")

Set view2 = db.GetView("EmailBody")



Dim maildoc As New NotesDocument(db2)

Set doc = view.GetFirstDocument

Set doc2 = view2.GetFirstDocument

Set itemA = doc2.GetFirstItem( "EmailBody" )



Call itemA.CopyItemToDocument( maildoc, "Body" )



While Not(doc Is Nothing)

	'send it

	maildoc.Principal = "Perry W. Craig <pwcraig@ralcorp.com>"

	maildoc.Subject =  "Intranet Announcement & Policy Acknowledgment: ACTION REQUIRED"

	maildoc.Form = "Memo"



	Call maildoc.Send(False, doc.emailaddy)

	

	Set doc = view.GetNextDocument(doc)

Wend

End Sub

end of code*

Subject: Append Body?

You need to get a handle on the body item of the new document. Currently you’re just copying an item from one place into your new document.

So, if you do something like:

dim itemA as notesrichtextitem

set itemA = doc2.GetFirstItem(“EmailBody”)

dim itemB as notesrichtextitem

set itemB = itemA.copyitemtodocument(maildoc, “Body”)

You can then appendtext or whatever to itemB.

I hope that’s what you mean…

Also, as an FYI, you don’t need to get db2 at all. Just create maildoc in your current database, set the form to Memo and send it. It won’t be stored in your current database and when it gets sent it’s the receiving mailbox that recognises the Memo form.

Subject: Append Body? - YES!

Yes, that worked!

Thank you so much.

And in looking back as to what I was doing this morning, I was almost there…

I must return the favor now…scouring the forums to see if I can answer a question…

Subject: RE: Append Body?

10-4 Thanks Dan!I’ll try it out…