Solved

Deleting an attachment

Posted on 2002-07-04
17
261 Views
Last Modified: 2013-12-18
Hi,
i want to attach a picture to a document that contains a richtext field but before i must check if there is already one, if yes, i have to delete the old picture and attach another one. Does some one has the code to detect and delete this attacment if it exists?

Thanks,
Koray.
0
Comment
Question by:koray_uygun
  • 9
  • 8
17 Comments
 
LVL 10

Expert Comment

by:zvonko
Comment Utility
Attached objects can be deleted by removing $FILE items from the document. First value in this $FILE items is the attachment file name.

But this does not render the RichText field image. You have still an attachment icon without an attachment behind it.

Why is it not possible to recreate the RT field completely?

0
 

Author Comment

by:koray_uygun
Comment Utility
How can i "recreate the RT field completely"?
0
 
LVL 10

Expert Comment

by:zvonko
Comment Utility
Set item = doc.GetFirstItem("Body")
Call item.Remove
Set rtitem = doc.CreateRichTextItem("Body")
Call rtitem.AppendText("Book for Developer ages 19-91" )Call rtitem.AddNewLine(1)
Set object = rtitem.EmbedObject( EMBED_ATTACHMENT, "", "c:\book.pdf")


You see?

0
 
LVL 10

Expert Comment

by:zvonko
Comment Utility
Sorry, NewLine should be in a new line :)

0
 

Author Comment

by:koray_uygun
Comment Utility
At this line :
Set rtitem = doc.CreateRichTextItem("Body")
the debugger says that the Body rich text item already exists.
0
 
LVL 10

Expert Comment

by:zvonko
Comment Utility
After this two lines it can not be true:
Set item = doc.GetFirstItem("Body")
Call item.Remove


Can you send me your script so far to paunoski@freenet.de

0
 
LVL 10

Expert Comment

by:zvonko
Comment Utility
Hello Koray,

did you got my email?
I had to guess your email from Notes sender address, so please send your internet email address if you did not got at least one email from me.

So long,
zvonko
0
 

Author Comment

by:koray_uygun
Comment Utility
Hi, thanks for your mail Zvonko. I am working on 4.6 version so i think that's why notes doesn't understand strleft or strright command in the script... :-(
What does this command do?
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

Author Comment

by:koray_uygun
Comment Utility
So here what i've done:

                    PhotoFileNames = ""
                    If doc.hasembedded Then
                         Set rt=doc.getfirstitem("PhotAtt")
                         Forall ob In rt.embeddedobjects
                              If ob.type=embed_attachment Then
                                   PhotoFileNames = PhotoFileNames & "c:\temp\"&Ucase(ob.name) & ";"
                                   Call ob.extractfile("c:\temp\"&Ucase(ob.name))
                              End If
                         End Forall
                         If (PhotoFileNames <> "") Then
                              Set rtpers=docpers.getfirstitem("PhotAtt")
                              Call rtpers.Remove
                              Set rtitem= doc.CreateRichTextItem("PhotAtt")
                              Do While (PhotoFileNames > "")
                        '          Set object=rtitem.EmbedObject( EMBED_ATTACHMENT, "", Strleft(PhotoFileNames, ";"))
                                   Set object=rtitem.EmbedObject( EMBED_ATTACHMENT, "", "c:\temp\"&Ucase(o.name) )
                            '       PhotoFileNames = Strright(PhotoFileNames, ";")
                              Loop
                         End If
                         docpers.PhotoName=doc.PhotoName(0)
                    End If

And it says still the same thing that the RichText Item PhotAtt already exists...
0
 
LVL 10

Accepted Solution

by:
zvonko earned 100 total points
Comment Utility
Sorry,

change this:
If (PhotoFileNames <> "") Then
     Set rtpers=docpers.getfirstitem("PhotAtt")
     Call rtpers.Remove
     Set rtitem= doc.CreateRichTextItem("PhotAtt")
     Do While (PhotoFileNames > "")
                       '          Set object=rtitem.EmbedObject( EMBED_ATTACHMENT, "", Strleft(PhotoFileNames, ";"))
          Set object=rtitem.EmbedObject( EMBED_ATTACHMENT, "", "c:\temp\"&Ucase(o.name) )
   '       PhotoFileNames = Strright(PhotoFileNames, ";")
     Loop
End If

to this:
If (PhotoFileNames <> "") Then
  Delete rt
  Set item=docpers.getfirstitem("PhotAtt")
  Call item.Remove
  Set rtitem= doc.CreateRichTextItem("PhotAtt")
  Do While (PhotoFileNames > "")
    Set object=rtitem.EmbedObject( EMBED_ATTACHMENT, "", Strleft(PhotoFileNames, ";"))  
    PhotoFileNames = Strright(PhotoFileNames, ";")
  Loop
End If

declare this new item in header section like this:
Dim item As NotesItem

This declaration is then obsolete:
Dim rtpers As notesrichtextitem

Sorry that I can not test this in advance. It is much less work when you test it opposite when I have to simulate it.

Tell me the next effects.

So long,
zvonko


0
 
LVL 10

Expert Comment

by:zvonko
Comment Utility
Oh,

one more thing to check...

Look in such a document where PhotAtt has to be removed how much PhotAtt items are currently present in this document. They could be more then one.

Best to see is this in document property dialog in Notes client.

0
 

Author Comment

by:koray_uygun
Comment Utility
SorryZvonko but at that line :
Set rtitem= doc.CreateRichTextItem("PhotAtt")

it still does not want to create another rtitem PhotAtt.
0
 

Author Comment

by:koray_uygun
Comment Utility
And i have looked, there's only one PhotAtt item in the document.
0
 
LVL 10

Expert Comment

by:zvonko
Comment Utility
OK, then I have to simulate...

But this takes a while :)

Meanwhile perhaps other experts around here can have a look.

So long,
zvonko

0
 

Author Comment

by:koray_uygun
Comment Utility
;-)
0
 

Author Comment

by:koray_uygun
Comment Utility
This works Zvonko!! I am so stupid, i have made a mistake in the code here :
 Set item=docpers.getfirstitem("PhotAtt")
 Call item.Remove
 Set rtitem= doc.CreateRichTextItem("PhotAtt")

The third line is not good, it must be :
 Set rtitem= docpers.CreateRichTextItem("PhotAtt")

So thanks for all!!
0
 
LVL 10

Expert Comment

by:zvonko
Comment Utility
Don't tell "stupid"
'cause I am this then too, repeating your mistake :)

Thanks for the points and for funny working together.

'till next time,
zvonko
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

  In today’s Arena we can’t imagine our lives without Internet as we are highly used to of it. If we consider our life style just for only 2 min we found that face to face communication is swapped by e-communication.  Every Where from Works place to…
Lack of Storage capacity is a common problem that exists in every field of life. Here we are taking the case of Lotus Notes Emails, as we all know that we are totally depend on e-communication i.e. Emails. This article is fully dedicated to resolvin…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now