Hi ,
I am struggling with an issue that has to create an Agent that append the Some predefined Text to the Mail Body before it reaches to the Mail Box…
Is any one who come with proper solution
Thanks in advance…
Regards,
Tim
Hi ,
I am struggling with an issue that has to create an Agent that append the Some predefined Text to the Mail Body before it reaches to the Mail Box…
Is any one who come with proper solution
Thanks in advance…
Regards,
Tim
Subject: Editing Email before it arrive to the Recipient Mail box…
create an agent with RunTime Option as “Before New Mail Arrives” . DocumentContext will give handle to the mail document
Subject: RE: Editing Email before it arrive to the Recipient Mail box…
Hey pravin…thanks for ur response…
but i have already an agent that respond “before new mail arrives”. two such type of agent can not be possible.
The situation is slightly different…the case is when an user send a mail to the mail box ,the mail box auto respond to that user at the same time it need to add some more text to the user mail when it reaches to the mail box…I have created an auto reply agent with “before a new mail arrive”.but at the same time i am not able to add some text to the that mail when it reaches to the mail box.
have any idea then plz share
Subject: RE: Editing Email before it arrive to the Recipient Mail box…
You should be able to do both in the same agent as you have the handle to the mail document. But adding too much code in “before new mail…” agent is not advisable. In fact using “before new mail…” agent itself is not a good idea.
But if you still want to use then, in the “before new mail agent” code for adding text to the mail and create a separate “after new mail arrives” agent for auto response. You can have any number of “after new mail…” agents.
Subject: RE: Editing Email before it arrive to the Recipient Mail box…
Sub Initialize Dim session As New NotesSession
Dim db As NotesDatabase
Set db = session.CurrentDatabase
Dim doc As New NotesDocument(db)
Set doc=session.DocumentContext
Call doc.AppendItemValue("From", "doc.From")
Call doc.AppendItemValue("Subject", _
"Meeting time changed")
Dim richStyle As NotesRichTextStyle
Set richStyle = session.CreateRichTextStyle
Dim richText As New NotesRichTextItem(doc, "Body")
Call richText.AppendText("The meeting is at ")
richStyle.Bold = True
Call richText.AppendStyle(richStyle)
Call richText.AppendText("3:00")
richStyle.Bold = False
Call richText.AppendStyle(richStyle)
Call richText.AppendText(" not ")
richStyle.StrikeThrough = True
Call richText.AppendStyle(richStyle)
Call richText.AppendText("2:00")
Call doc.Save(True, False)
Call doc.Send(False,"doc.To")
End Sub
I added this code just to apend some text but not able to get the handle of coming email append it to them…
If u have the proper code then …plz share…i have did wht i can do…but no result…If possible then plz do as earlier as u can…
Regards,
Tim
Subject: RE: Editing Email before it arrive to the Recipient Mail box…
This is a simple “before new mail” agent which will change the mail subject and append text to the body of the email.
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Set db = session.CurrentDatabase
Set doc=session.DocumentContext 'This is the mail document
'Change the subject
doc.Subject = “This is a new subject”
'Adding text to the Mail body
Dim rtItem As Variant
Set rtItem = doc.GetFirstItem( “Body” )
If rtItem.Type = RICHTEXT Then
'Add all your new text here
Call rtItem.AddNewLine( 2 )
Call rtItem.AppendText (“This is a new text added to the mail body”)
End If
Call doc.Save(True, False)
End Sub
This is a sample “Auto Reply” agent which you can set to run as “After new mail arrives”
Sub Initialize
Dim s As New notessession
Dim db As NotesDatabase
Dim coll As NotesDocumentCollection
Dim doc As NotesDocument
Dim maildoc As notesdocument
Dim rtbody As NotesRichTextItem
Dim FromName As NotesName
Dim SendToName As NotesName
On Error Goto ErrHandler
Set db=s.CurrentDatabase
Set coll=db.UnprocessedDocuments
Set doc=coll.GetFirstDocument
If coll.Count > 0 Then
Set doc=coll.GetFirstDocument
While Not doc Is Nothing
Set SendToName = New NotesName(doc.SendTo(0) )
Set FromName = New NotesName(doc.From(0) )
If (doc.Form(0) <> “NonDelivery Report”) And (doc.MessageType(0) <> “FAX”)And (SendToName.Common <> FromName.Common) Then
Set maildoc=db.CreateDocument
maildoc.Subject="Re: " + doc.Subject(0)
maildoc.sendto=doc.From
maildoc.form = “Memo”
maildoc.PostedDate = Now
Set rtbody=maildoc.CreateRichTextItem(“Body”)
Call rtbody.AppendText(“This is an Auto-Response”)
Call maildoc.Send(False)
Call maildoc.Save(True, True)
End If
Call s.UpdateProcessedDoc( doc )
Set doc=coll.GetNextDocument(doc)
Wend
End If
Exit Sub
ErrHandler:
Print "Error in Auto-Reply agent : " & Error$ & “on line " & Cstr(Erl) & " – From” & doc.From & " - at " & Cstr(doc.time(0)) & " - Subject: " & doc.Subject(0)
Resume Next
End Sub