Manage Learn to apply best practices and optimize your operations.

Bring e-mail into a DB as a response document

Bring E-Mail from Mail File into another DB as a response document

I have had many requests to attach an e-mail to a document in a Notes database. The code below will allow you to select one or more documents in a database and then select one or more e-mails to attach to the document(s).

The code assumes there is a form called Memo in the target database that has text fields called From, SendTo, CopyTo, BlindCopyTo, Subject, and a richtext field called Body.

The code may be used in an action button.


Sub Click(Source As Button) Const FormName$ = "Memo" ' The name of the memo form to create in target DB Dim ws As New NotesUiWorkspace Dim db As NotesDatabase Dim vMailInfo As Variant Dim dcEMail As NotesDocumentCollection Dim dcSource As NotesDocumentCollection Dim docEMail As NotesDocument Dim docSrc As NotesDocument Dim docMemo As NotesDocument Dim SrcDoc As Integer Dim eMail As Integer Dim rtMemo As Variant Dim rtEMail As Variant Dim answer As Integer vMailInfo = Evaluate( "@MailDbName" ) ' Get the server name and filename of the mail database Set dcEMail = ws.PickListCollection( PICKLIST_CUSTOM, True, vMailInfo(0), vMailInfo(1), _ "($Inbox)", "Bring E-Mail From Mail File", "Please select one or more e-mails to attach to currently selected document" ) If dcEMail.Count = 0 Then Exit Sub End If answer% = 4 + 32 + 256 ' YesNo prompt + Question icon + No as default ( using this variable to feed and get info to messagebox) answer% = Messagebox("This will copy " + Trim( Str( dcEMail.Count ) ) + _ " e-mail(s) to the selected documents (all checked documents).", answer% , "Do you want to continue?") If answer% = 6 Then ' If Yes Set db = ws.CurrentDatabase.Database For eMail% = 1 To dcEMail.Count Set docEMail = dcEMail.GetNthDocument( eMail% ) ' Get a handle on the Nth document from the Notes Collectionn Set dcSource = db.UnprocessedDocuments ' Get a collection of select source documents If Isempty( dcSource ) Then Messagebox "No E-Mail(s) were selected for processing.", 64, "No E-Mail(s) Selected" Exit Sub End If For SrcDoc% = 1 To dcSource.Count ' Loop through the source document selected Set docSrc = dcSource.GetNthDocument( SrcDoc% ) ' Get a handle on the Nth source document Set docMemo = db.CreateDocument ' Set the fields on the Source Document docMemo.Form = FormName$ docMemo.From = docEMail.From docMemo.SendTo = docEMail.SendTo docMemo.CopyTo = docEMail.CopyTo docMemo.BlindCopyTo = docEMail.BlindCopyTo docMemo.Subject = docEMail.Subject If docEMail.HasItem( "Body" ) Then ' Inbox items like mail router notices have no Body field Set rtMemo = docMemo.CreateRichTextItem( "Body" ) Set rtEMail = docEMail.GetFirstItem( "Body" ) If ( rtMemo.Type = RICHTEXT And rtEMail.Type = RICHTEXT ) Then Call rtMemo.AppendRTItem( rtEMail ) ' Add richtext from e-mail to new memo End If End If Call docMemo.MakeResponse( docSrc ) ' Make new Memo as response to selected document Call docMemo.Save( False, True ) ' Save the new response document Next ' DcSource Next ' dcEMail Else Messagebox "The process has been cancelled.", 48, "Process Cancelled" End If End Sub

Dig Deeper on Domino Resources - Part 2

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchWindowsServer

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchDataCenter

SearchContentManagement

Close