Replace attachment with text ( like response without attach. )

Hello,

I need to write some code like “Response without attachment” action.

The code I write remove the attachment but put the text at the end of RTF. I need to put the text instead of the attach.

Any ideas?

Thank’s in advance.

Joseph

Subject: Replace attachment with text ( like response without attach. )

Did you check the mail template? It holds the same code.

Subject: RE: Replace attachment with text ( like response without attach. )

Yes, I check it, but I haven’t found anything.

I check “Response without attachment”:

@Command([ComposeWithReference];“”:“”;“Reply”; 23)

This is not good for me, because I don’t must remove all the attachments of the RFT.

Thank you

Subject: RE: Replace attachment with text ( like response without attach. )

As you would like to access the doclink or embedded object separately from the text so you can remove it, look at the NotesEmbeddedObject class, contained by NotesRichTextItem class and RichTextNavigator class. There’s a .Remove method.

Subject: RE: Replace attachment with text ( like response without attach. )

Yes I know this class. I CAN remove the attach, but I want to remove and replace it for text.

My RTF contains this:

First line ( text )

Second line ( attach. )

Third line ( text )

This is I want to get:

First line ( text )

Second line ( text replacing the attachment )

Third line ( text ).

Whit the next code I got this:

First line ( text )

Second line ( nothing )

Third line ( text )

Fourth line ( text replacing the attachment )

The code …

Sub Initialize

Declarations

Set db = session.CurrentDatabase

Set dc = db.UnprocessedDocuments

Set doc = dc.GetFirstDocument

auxTemp = Environ( “Temp” )

If Dir( auxTemp + "" + “Removed”, 16 ) = “” Then

  Mkdir auxTemp + "\" + "Removed"

End If

While Not doc Is Nothing

  If doc.HasEmbedded Then 

     Set rtitem = doc.GetFirstItem( "Body" ) 

     Set nav = rtitem.CreateNavigator 

     Set objet = nav.GetFirstElement( 8 ) 

        While Not objet Is Nothing 

auxName = objet.Name 

If Strrightback( auxName, "." ) = "gif" Then ' To delete ".gif" attachments

   auxPath = auxTemp + "\" + "Removed" + "\" + auxName

   Call objet.ExtractFile( auxPath ) 

   Call objet.Remove 



   Set rtStyleText = session.CreateRichTextStyle 

   rtStyleText.Bold = False 

   rtStyleText.NotesColor = COLOR_DARK_BLUE 

   rtStyleText.Underline = False 

   rtStyleText.NotesFont = FONT_HELV 



               rtStyleText.FontSize = 8 

               Call rtitem.AddNewLine( 2 ) 

               Call rtitem.AppendStyle( rtStyleText ) 

   Call rtitem.AppendText( "Removed attachment: " + auxName ) 

   Call rtitem.AddNewLine( 1 ) 

End If 



            Set objeto = nav.GetNextElement( 8 ) 

        Wend 

        doc.Save True, True 

     End If 

  Set doc = dc.GetNextDocument( doc )

Wend

End Sub

Subject: RE: Replace attachment with text ( like response without attach. )

I’ve not tried this but it seems you are going to need to control the insertion point for the ‘text replacing the attachment’, for now you are using the AppendText method which by default wants to insert the text at the end of the RichTextItem.

From Help:

AppendText method

Example

Inserts text in a rich text item. The text is rendered with the current style of the item (such as bold or italics).

Defined in NotesRichTextItem

Syntax

Call notesRichTextItem.AppendText( text$ )

Parameters

text$

String. The text to append.

Usage

By default the insertion occurs at the end of the item. You can change the insertion point with BeginInsert and EndInsert.