0 pts.
 Send mail as admin@domain.xxx and not from server when webform submit
Hi, I am new to domino and still fight to win LotusScript although the logic of its workflow is understandable (So I was thinking) Anyway. I have a webform that gets filled in by registered webusers (Without a mailbox). In this form they fill a name and email of another person that is not registered. When they submit this form, it should send a mail to the given mailbox on the form by the server as for instance from the admin@domain.xxx mailbox, with a simple text message. I used a sullotion to try and solve my problem and got the following error,,, (NOW I AM STUCK). Please look at my code and tell me what I am doing wrong! My Code: Sub Initialize Dim session As New NotesSession Set newnote = New NotesDocument(db)<----(Error) newnote.Subject = "Subject: " & doc.YourSubjectField(0) newnote.From = "admin@domain.xxx" newnote.SendTo = "whomever@something.com" newnote.CopyTo = "copyto@something.com" newnote.Form = "Memo" Set rtItem = New NotesRichTextItem(newnote , "Body" ) Set style = session.CreateRichTextStyle style.Bold=True Call rtitem.AppendStyle(style) Call rtItem.AppendText(doc.YourFieldInBold(0)) style.Bold=False Call rtitem.AppendStyle(style) Call rtItem.APPENDTEXT("Dear " & director & " " + surname & ", " ) Call rtItem.ADDNEWLINE(2) Call rtItem.AppendText(" More text, whatever you want.") Call newnote.Send(False) End Sub The Error: Initialize: 3: type mismatch on: DB

Software/Hardware used:
ASKED: July 27, 2006  6:01 PM
UPDATED: July 28, 2006  11:39 AM

Answer Wiki:
You need to declare and instantiante the db, newnote and doc variables. This will get you past the first error, Your code will then bomb on the line after the error unless you set doc = to something (like you did with the newnote, you must set the doc = to a notes document (like the current document) in order to get the value of the Subject field). Good luck. Dim session As New NotesSession Dim db as NotesDatabase DIm newnote as NotesDocument Set db = s.CurrentDatabase Set newnote = New NotesDocument(db)<----(Error) newnote.Subject = "Subject: " & doc.YourSubjectField(0)
Last Wiki Answer Submitted:  July 28, 2006  7:14 am  by  MHanson   35 pts.
All Answer Wiki Contributors:  MHanson   35 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

Change your code as below:
Sub Initialize
Dim session As New NotesSession
Dim db as NotesDatabase ‘new line
set db = session.CurrentDatabase ‘new line, if you needed
‘a db other than current use methods GetDatabase(“dbname”)
Set newnote = New NotesDocument(db)

 0 pts.

 

when you fix the errors as suggested in reply 1 and 2, you will end up with the problem, that you can’t change the sender of the mail. domino will set it to the agent’s signer.

See http://www-10.lotus.com/ldd/46dom.nsf/7e6c7e584a76331b85256a46006f083e/574c99ccb345839185256976004e811e?OpenDocument
and
http://www-128.ibm.com/developerworks/lotus/library/ls-Troubleshooting_agents_ND5_6/
(How can I change the apparent sender of agent generated mail?)

 0 pts.

 

Try declaring your variables and setting the db object before use.

Sub Initialize
Dim session As New NotesSession
Dim db as NotesDatabase
Dim newnote as NotesDocument
Set db = session.CurrentDatabase
Set newnote = New NotesDocument(db)
newnote.Subject = “Subject: ” & doc.YourSubjectField(0)
‘…. and so on …

 0 pts.