Sending Mail with Form Embedded

I have created this small Payroll Database for my company. It contains a “sendto” & “Copyto” fields. Also it contains a field called “month” which is the transaction month. I need to send each user his document not as an attachment (Document Embedded in Mail) and I need to have the subject containing field “month”. I have tried the @MailSend but failed, also I always try to keep out of script. Can someone please help.

Subject: Script is probably easiest. There are at least 3 ways to send the doc.

First would be to just create a memo and have a document link back to the actual document. Dim s As New NotesSession

Dim db As NotesDatabase

Dim v As NotesView

Dim doc As NotesDocument

Dim mdoc As NotesDocument

Dim rt As NotesRichTextItem

Set db = s.CurrentDatabase

Set v = db.GetView("AllDocsByEmployeeName")

Set doc = v.GetFirstDocument

While Not (doc Is Nothing)

	Set mdoc = db.CreateDocument

	mdoc.Form = "Memo"

	mdoc.SendTo = doc.SendTo

	mdoc.CopyTo = doc.CopyTo

	mdoc.Subject = "Your Document for Month " +Cstr(doc.Month(0)) + " is here."

	Set rt = mdoc.CreateRichTextItem("Body")

	Call rt.AppendText("Please follow this link to your monthly document -->")

	Call rt.AppendDocLink(doc, "Link to Monthly Doc", "Link to Monthly Doc")

	Call mdoc.Send(False)

	Set doc = v.GetNextDocument(doc)

Wend

Second would be ot mail the document with Store Form in document set.

Dim s As New NotesSession

Dim db As NotesDatabase

Dim v As NotesView

Dim doc As NotesDocument

Dim mdoc As NotesDocument

Dim rt As NotesRichTextItem

Set db = s.CurrentDatabase

Set v = db.GetView("AllDocsByEmployeeName")

Set doc = v.GetFirstDocument

While Not (doc Is Nothing)

	doc.Subject = "Your Document for Month " +Cstr(doc.Month(0)) + " is here."

	Call doc.Send(True)

	Set doc = v.GetNextDocument(doc)

Wend

Third would be to render the document to the body of the mail document

Dim s As New NotesSession

Dim db As NotesDatabase

Dim v As NotesView

Dim doc As NotesDocument

Dim mdoc As NotesDocument

Dim rt As NotesRichTextItem

Set db = s.CurrentDatabase

Set v = db.GetView("AllDocsByEmployeeName")

Set doc = v.GetFirstDocument

While Not (doc Is Nothing)

	Set mdoc = db.CreateDocument

	mdoc.Form = "Memo"

	mdoc.SendTo = doc.SendTo

	mdoc.CopyTo = doc.CopyTo

	mdoc.Subject = "Your Document for Month " +Cstr(doc.Month(0)) + " is here."

	Set rt = mdoc.CreateRichTextItem("Body")

	Call doc.RenderToRTItem(rt)

	Call mdoc.Send(False)

	Set doc = v.GetNextDocument(doc)

Wend

Subject: Forgot to mention something

Thanks for your quick response. I need to create an action button in a certain view that will send mail for the selected people.

Subject: Then change your outside loop…

Put this code in an Agent that runs on Selected Documents. Put @Command([ToolsRunMacro]; “YourAgent”) in the Action button. Dim s As New NotesSession

Dim db As NotesDatabase

’ Dim v As NotesView

Dim dc As NotesDocumentCollection

Dim doc As NotesDocument

Dim mdoc As NotesDocument

Dim rt As NotesRichTextItem

Set db = s.CurrentDatabase

’ Set v = db.GetView(“AllDocsByEmployeeName”)

Set doc = dc.GetFirstDocument

While Not (doc Is Nothing)

	doc.Subject = "Your Document for Month " +Cstr(doc.Month(0)) + " is here."

	Call doc.Send(True)

	Set doc = dc.GetNextDocument(doc)

Wend