Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

maildoc.sendto...variable name 1

Status
Not open for further replies.

cramd

Programmer
Mar 28, 2001
214
US
I am stuck on the sendto line of this code....examples that I have found show hardcoded email addresses with sendto, I am trying to get the email address to be a variable from my test file:

my database - test.nsf
my view - testview
my column within testview - emailaddress
so I thought I could do this ---> maildoc.sendto="emailaddress" OR
maildoc.sendto=emailaddress
but no luck.....
**********************************************

dim session as new notessession
dim db as notesdatabase
dim view as notesview
dim doc as notesdocument
dim maildoc as notesdocument
dim olddoc as notesdocument

set db=session.currentdatabase
set view=db.getview("testview")
set doc=view.getfirstdocument
do while not doc is nothing
set maildoc=db.createdocument
maildoc.form="Memo"
call copyelements(maildoc,doc)
'maildoc.sendto="recipient_name"
maildoc.sendto="email"
call maildoc.send(false,maildoc.sendto(0))
****************************************************
Any hints would be appreciated!
Diane
 
I think I have understood your problem : you want to send a mail for each document you have in a view.

Your code is almost fine. Let's step through it :

1) you load the database
2) you get the view
3) you load the first document in the view
4) you start the loop
5) you create a new document
6) you correctly set the "Memo" form name
7) you copy every field from the working doc to the new doc
8) you set the SendTo field to a wrong value

Your mistake is to have forgotten where the email address comes from. If it is from the working document itself, then you should specify something like :

maildoc.sendto = doc.email(0)

That is where your "variable" is.

Oh, one more thing : the above instruction supposes that the Email field only contains one address. If you do multiple recipients, you'll have to use two NotesItem objects and append values from the current doc to the maildoc.

Good luck !

Pascal.
 
That was it!!!! THANK YOU THANK YOU........ O.K., now explain this to me....
maildoc.sendto = doc.email(0) - I'm not understanding the parameter(0) - what are my choices with this??
I'm sure I'll be back for more Q&A, but you've got me started now.....
Thanks again, you earned a star!!
cramd

 
What you must understand is that any field in a document record is a table of values. If the field is not multi-value, then you can only reference the first index value, which is obviously at position 0.

In a multi-value field, you will have as many index values as there are values in the field. So, for a field containing the days of the week, you will be able to reference doc.weekday(0)..(6).

Now for the tricky part : you must give an index reference when you are reading a value, but you must not when you are setting a value in a non-multi-value field.

In other words, you can write doc.username="John Doe" when you want to set the field, but you must write uname=doc.username(0) when you want to retrieve the value in a temp variable.

I hope I've cleared that up for you.

Have fun !

Pascal.
 
Pascal,
I understand what you are saying, I have not "toyed" with multiple value fields yet but now I realize how I can work with these fields. I have worked with arrays and indexes in other languages which helps me now while trying to figure out coding in Lotus.
Your posts have been very helpful!
cramd
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top