Solved

Deleting an attachment

Posted on 2002-07-04
17
264 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 9
  • 8
17 Comments
 
LVL 10

Expert Comment

by:zvonko
ID: 7129605
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
ID: 7129681
How can i "recreate the RT field completely"?
0
 
LVL 10

Expert Comment

by:zvonko
ID: 7129915
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 10

Expert Comment

by:zvonko
ID: 7129920
Sorry, NewLine should be in a new line :)

0
 

Author Comment

by:koray_uygun
ID: 7129958
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
ID: 7130020
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
ID: 7131204
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
ID: 7131237
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
 

Author Comment

by:koray_uygun
ID: 7131256
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
ID: 7131570
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
ID: 7131574
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
ID: 7131757
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
ID: 7131760
And i have looked, there's only one PhotAtt item in the document.
0
 
LVL 10

Expert Comment

by:zvonko
ID: 7131844
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
ID: 7131924
;-)
0
 

Author Comment

by:koray_uygun
ID: 7132437
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
ID: 7132900
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Lotus notes view not working using Trim 14 214
Entry not found in index or view's index not built 4 110
Lotus Notes Calendar Help 6 105
xss alert in domino url 9 54
You’ve got a lotus Domino web server, and you have been told that “leverage browser caching” is a must do. This means that we have to tell the browser everywhere in the web to use cache. In other words, we set (and send) an expiration date in the HT…
Article by: Rob
Notes 8.5 Archiving Steps and Tips This article covers setting up a Notes archive, and helps understand some of the menu choices making setting up and maintaining a Notes archive file easier.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

756 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