Author: 
                    Ruediger Seiffert  
 Date: 
                    Thursday, 1/28/99 5:10 PM EST  
 Subject: 
                    Re: Help. Agent to kick off email after web post 
 
 
 
 
Hi, 
 
ok, you can "steal" the following. 
Ruediger  
 
I suppose you have a flag in your faq-document which will be set if it´s answered 
(faq_answered="true").  
Create another flag which will prevent multiple sending of the same message: 
 
Field (editable - hidden):  
email_already_sent 
Default Value: "false" 
 
Then put the following in the documents QueryClose-Event 
 
Sub QueryClose(Source As Notesuidocument, Continue As Variant) 
Dim doc as NotesDocument 
Dim var1 As String 
... 
Dim varN As String 
Dim s as New NotesSession 
 
Set doc = source.Document 
var1 = doc.Field1(0) 
... 
 
If doc.faq_answered(0)="true" and doc.email_already_sent(0)="false" Then 
Call SentNotification(var1, ..., varN, Mailaddress) 
doc.email_already_sent(0)="true" <---- This prevents multiple EMail-Notifications 
Call doc.Save(True, False) <---- I don´t know if this is necessary for QueryClose - test it ;-) 
End If 
End Sub  
 
 
 
And this is your SUB: 
 
Sub SentNotification(s As NotesSession, replytoaddr as String, emailaddr As String) ' <---- Define the variables you need in the same order then you give them to this Sub 
 
Dim s As New NotesSession  
Dim mailDoc As New NotesDocument(s.CurrentDatabase) 
mailDoc.SaveMessageOnSend = False 
Call mailDoc.ReplaceItemValue("Form", "Memo") 
Call mailDoc.ReplaceItemValue("SendTo", emailaddr )					' SendTo can either be canonical or an email address 
Call mailDoc.ReplaceItemValue("Subject", "Your subject goes here.") 
 
 ' you can create "Copy", "BlindCopy" etc. in the same manner 
 
' note that some of the entries below MUST be email addresses and not canonical names 
fromuser = thisAgent.OnBehalfOf			' canonical format ( Agent runs on behalf of a specific user.) 
replytoaddr = doc.ReplyTo(0)				' e-mail format, not canonical 
If (replytoaddr ="") Then 
	' cannot have "", will get Invalid User error for SMTP 
	replytoaddr ="somebody@mindwatering.net" 
End If 
mailDoc.From = replytoaddr 					' can be canonical if person doc exists, otherwise make email address format 
mailDoc.ReplyTo = replytoaddr					' must be email address format 
mailDoc.Principal = fromuser					' should be canonical 
mailDoc.INetFrom = replytoaddr 				' must be email address format 
 
' build the body field 
Dim rtitem As New NotesRichTextItem( mailDoc,"Body") 
Call rtitem.AppendText("Bla Bl Bla " & UName & "!")  
Call rtitem.AddNewLine(1) 
Call rtitem.AppendText("More and more Text")  
Call rtitem.AddNewLine(1) 
...... 
...... 
 
Call mailDoc.Send( False, emailaddr ) 
End Sub 
 
 
  
previous page
 
  |