Save/delete attachment action

Hi designers,

R6 has the new attachment functions, which delete or save the attachment and replaces it in the message with [attachment name…].

Could I find this function somewhere in the mail file design? I searched in the actions & agents - without result.

Or is there any sample code how to use this?

We would like to implement this feature on view level, so that the user can select a number of mails and delete the attachments (and places attachment names and deletion info).

thanks for any hints

Uwe

Subject: save/delete attachment action

This functionality is hardcoded in the Notes Client and works with any database. You do not need to modify database design to use it.

However, this functionality is not available at view level. For use at view level, you must add own code to the database design (e.g. as View Action or Agent).

Subject: thank you Dietmar - I feared that…

but maybe anybody knows a code sample for this?

Great thanks in advance!

Uwe

Subject: RE: thank you Dietmar - I feared that…

I’ve been using this agent for years. Moved it over from 5 to 6 as an action bar button. This only deletes the attachements from selected items in a view. Now if somebody knows an agent to automatically strip attachments from all Reply and Reply with History?

Sub Initialize

Dim Continue As Integer

Continue = Msgbox("You are about to delete all of the attachments from the documents that you have selected. Are you sure you want to continue?",292,"Delete Attachments")



If Continue = 6 Then ' 6 = Yes 7 = No

	DeleteAttachments

End If

End Sub

Sub DeleteAttachments

Dim Session As New NotesSession

Dim Db As NotesDatabase

Dim DocCollection As NotesDocumentCollection

Dim Doc As NotesDocument

Dim Field As NotesRichTextItem

Dim countera As Integer

Dim counterb As Long

Dim Style As NotesRichTextStyle

Set Db = Session.CurrentDatabase

Set DocCollection = Db.UnprocessedDocuments

Set Doc = DocCollection.GetFirstDocument

Set Style = Session.CreateRichTextStyle

Style.FontSize = 4 

Style.NotesColor = 4 '4 = Blue



While Not (Doc Is Nothing)

	If Doc.HasEmbedded Then

		Set Field = Doc.GetFirstItem("Body")

		Call Field.AddNewLine(3)

		Style.Underline = True 

		Call Field.AppendStyle(Style) 

		Call Field.AppendText("You have removed the following files from this document to conserve space:")

		Forall x In Field.EmbeddedObjects 

			If x.Type = 1454 Then '1454 means the embedded object is an attachment

				countera = countera + 1 

				counterb = counterb + x.filesize

				Style.Underline = False

				Call Field.AppendStyle(Style)

				Call Field.AddNewLine(1)

				Call Field.AppendText("(" & x.Name & ")")

				Call x.Remove

				Call Doc.Save (True,True) 

			End If

		End Forall

	End If

	Set Doc = DocCollection.GetNextDocument(Doc) 

Wend



If countera > 0 Then

	

	Msgbox "Thank you for cleaning your mailbox!" & String$(2,Chr(13)) & "Attachments Deleted: " & countera & Chr(13) & "Space Recovered: " & Cstr(Cint(counterb/1024)) & " Kb" & String$(2,Chr(13)) & "Note: The recovered space will be reallocated after the database is compacted." & Chr(13) ,48,"Delete Attachments"

Else

Subject: save/delete attachment action

I’m also hunting for a code example for accessing the delete attachment (and delete all attachment) functionality of the client.

I’d like to make a agent that deletes attachments for messages that exist in a shared mail database (not SHARED mail, but a mail-in database that is in the same mail group as a bunch of people). I’d like to also put a doc-link to the “shared” document next to the [attachment name…] deleted text…

Thanks!