SendTo?

I want to send an email with the recipient to be dynamic from the field not static. It works fine if I put in the newDoc.SendTo = “Joe Smith”

BUT I am getting an error “Object variable not set” when I use this - newDoc.SendTo = doc.Dupont_ROS_Verifier(0)

My Code:

Dim session As New NotesSession

Dim db As NotesDatabase

Dim doc As NotesDocument

Set db = session.CurrentDatabase

Set dc = db.unprocesseddocuments

Call dc.StampAll(“Status”, “Requires Validation”)

Dim view As NotesView

Dim newDoc As NotesDocument

Dim rtitem As NotesRichTextItem

Set view = db.GetView( “Import” )

Set newDoc = New NotesDocument( db )

Set rtitem = New NotesRichTextItem( newDoc, “Body” )

Call rtitem.AppendDocLink _

( view, view.Name & " in " & db.Title )

newDoc.Subject = “Here is a link to the - My Verificaion - by Status View”

Messagebox "Name : " & doc.Dupont_ROS_Verifier(0)

newDoc.SendTo = doc.Dupont_ROS_Verifier(0)

Call newDoc.Send( False )

Subject: Your doc is not set

Subject: RE: Your doc is not set

EOM ?

Subject: RE: Your doc is not set

EOM = End of Message. Not a particularly useful response… just my opinion. He mentioned the doc not being set. You might try “set doc = newdoc” under your set newdoc=newnotesdocument(db). It is probably having an issue with the newdoc… = doc… line at the end.

Subject: RE: Your doc is not set

Now I am getting a blank value in that field BUT there is a value in the field??

Subject: RE: Your doc is not set

You might try (like your newdoc) setting doc vs. “set doc = newdoc”. This could be causing your blank. Maybe “Set doc As NotesDocument”. If the object error is on that line then it should be that doc is not set (since newdoc is).

Subject: RE: Your doc is not set

It already is. What is going on here??

Subject: RE: Your doc is not set

Anthony, let me see if I can help clear this up for you.

In your original post on this, you had asked how to modify a field on documents that you had selected, and someone said to use db.UnprocessedDocuments to get a collection, so you did that.

Next, in the code you posted after that you were looping through the collection to set the Status field to “Requires Validation”, and Esther had said to use the NotesDocumentCollection.StampAll method to set the field value, since it saves not having to loop through the collection. You did that.

You then added the part to the code to send an email once that was done. In your code, you want to get the email address from the Dupont_ROS_Verifier field in a document, so you tried using doc.Dupont_ROS_Verifier(0) as the source for that address. The only thing is that you haven’t specified what document is referenced by doc. If, as Stan said, that document is the doucment currently open in the UI, then what Stan said is good. If not, then you have to get a handle to the document before you can reference the data in the document.

Now, you do have a line in the code which says

Set view = db.GetView( “Import” )

so maybe the document with the email address is in that view. I don’t know. If it is, then you need to look up the document in the view.

HTH

Subject: RE: Your doc is not set

Unless I missed something, doc is DIM but not SET (like newdoc). The line that you are receiving the error on is wanted both newdoc and doc set. I could be way off… but that is what it looks like to me. The error you are receiving is usually related to something not being DIM/SET.

Subject: RE: Your doc is not set

A new pair of eyes tells me that “doc” is supposed to be an existing document – perhaps the document currently opened in the UI? If that is the case, then you (Anthony) will have to go through the NotesUIWorkspace to get a handle on the document. In your declarations portion (assuming it’s in the Click sub and not the actual Declarations), you’ll need to add:

Dim ws As New NotesUIWorkspace

Then to set the document “doc” you’d use:

Set doc = ws.CurrentDocument.Document

The means to get a handle to a document selected in a view, say, are different, so you’d need to tell us which document you’re trying to get the SendTo value FROM if this hasn’t solved your problem.

Subject: RE: Your doc is not set

I tried it all and still can’t get this to work?

Any more suggestions?

Thanks

Subject: RE: Your doc is not set

As Jerry and I have both said, you need to tell us exactly what you are trying to do before we can help you.

Subject: RE: Your doc is not set

The user selects one or multiple document in the view. Those documents that were selected get the value of “Requires Validation” put in the Status field - this works fine.

There is a field called Dupont_ROS_Verifier, which contains a name. Example: there can be 10 documents selected and there might be 4 names the same, 4 more same names, & the two remaining names are the same. I want to send an email out to only the three unique names. So only three emails will go out not all ten because the same person will get duplicate emails.

I hope this is clear and someone can help.

Thanks