Error "you must specify parent document"

I am trying to create an email routine, depending on user preference, sendsA = automatically

C = opens memo in compose mode

I can get it to work but would like to know the correct way of doing this.

I get " you must specify parent document" error if I code this way:

Set mailDb = New NotesDatabase(“”,“”)

If iSendOption = “A” Then

Set EmailDoc = mailDb.CreateDocument

Elseif iSendOption = “B” Then

Call mailDb.OpenMail

Set EmailDoc = mailDb.CreateDocument

End If

’ Error occurs here:

Set rtBodyitem = New NotesRichTextItem(Emaildoc, “Body”)

The problem goes away if I do:

If iSendOption = “A” Then

Set mailDb = New NotesDatabase(“”,“”)

Set EmailDoc = mailDb.CreateDocument

Elseif iSendOption = “B” Then

Set mailDb = New NotesDatabase(“”,“”)

Call mailDb.OpenMail

Set EmailDoc = mailDb.CreateDocument

End If

Set rtBodyitem = New NotesRichTextItem(Emaildoc, “Body”)

Syntatically, is the first way incorrect?

JJ

Subject: Error “you must specify parent document”

if does not work in the first, because your end if is in the wrong place.

WHne getting into this, you are sometimes better using a select case as in.

Set mailDb = New NotesDatabase(“”,“”)

select case iSendOption

case “A”

…

the code for what you want to do

case “B”

…

the code for what you want to do

case else

msgbox “Invalid Option”

exit sub

end select

Set rtBodyitem = New NotesRichTextItem(Emaildoc, “Body”)

Subject: RE: Error “you must specify parent document”

thanks for the tip, that solved my problem.