Manage Learn to apply best practices and optimize your operations.

Adding A File To All Docs In A View

The below code will add a file to all docs in a view:
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim rtitem As Variant
Dim dirname As String
Dim fileno As String
Dim filename As String
Dim filetext As String
Dim tfile As Variant

Set db = session.CurrentDatabase
Set view = db.GetView( "Mail Sent" )
Set doc = view.GetFirstDocument
Do While Not(doc Is Nothing)

Set tfile = doc.GetFirstItem("Body2")
If ( tfile.Type = RICHTEXT ) Then
Call tfile.AppendText( "For the HTML version of this
newsletter... " )
Call tfile.EmbedObject( EMBED_ATTACHMENT, "ASCII Text",
"E:\Temp\Extend.htm")
Call doc.Save( False, True )
End If

Call doc.Save(True, False)
Set doc = view.Getnextdocument(doc)
Loop
End Sub



This code removes said file attachment from all docs in a view

Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim rtitem As Variant
Dim dirname As String
Dim fileno As String
Dim filename As String
Dim filetext As String
Dim tfile As Variant
Dim object As NotesEmbeddedObject

Set db = session.CurrentDatabase
Set view = db.GetView( "Mail Sent" )
Set doc = view.GetFirstDocument
Do While Not(doc Is Nothing)
Set rtitem = doc.GetFirstItem( "Body2" )
If ( rtitem.Type = RICHTEXT ) Then
Forall o In rtitem.EmbeddedObjects
If ( o.Type = EMBED_ATTACHMENT ) Then
Call o.ExtractFile( "c:\temp\" & o.Source )
Call o.Remove
Call doc.RemoveItem( "Body2" )
Call doc.Save( False, True )
End If
End Forall
End If

Call doc.Save(True, False)
Set doc = view.Getnextdocument(doc)
Loop
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