hi,
i try renaming attachments with a shared action.
First I am extracting the attachments and then I try to reattach them with Lotusscript NotesrichtextItem.EmbedObject.
This works in most cases, but some pdf’s are not reattached correctly !!! So for example in one document a pdf and jpeg are renamed correctly, but the second pdf only shows as symbol in the document and clicking gives back an error like “Element of document not found” (sorry German Error Message).
Here my Code:
okSave = False
Set itbody = doc.GetFirstItem(“Body”)
If Not itbody Is Nothing Then
attlist =itbody.EmbeddedObjects
'Email auf Dateianhänge prüfen
If Not Isempty(attlist) Then
Forall attachFile In attlist
okRemove = False
If attachFile.Type=EMBED_ATTACHMENT Then
strFilename = attachFile.Source
'Want rename?
okRename = Messagebox("Möchten Sie jetzt den Anhang '" & _
strFilename & “’ umbennen?”, 3+32+0, “Anhang gefunden”)
If okRename=6 Then
strName = attachFile.Name
Forall i In doc.Items
If i.Name = "$FILE" Then
If i.Values(0) = strFileName Then
'Input here new Name
strNewFilename = Inputbox("Bitte den neuen Namen eingeben", "Anhang umbenennen", strFilename)
If Lcase(strNewFilename) = Lcase(strFilename) Or strNewFilename = "" Then
Msgbox "Abbruch: Der neue Name ist leer oder hat sich nicht geändert !"
Exit Forall
End If
attachFile.ExtractFile("C:\" & strNewFilename)
Set newEObj = itBody.EmbedObject(EMBED_ATTACHMENT, "", "C:\" & strNewFilename)
okRemove = True
okSave = True
Call attachFile.Remove()
Call i.Remove()
Exit Forall
End If
End If
End Forall
If okRemove Then
Kill "C:\" & strNewFilename
okRemove = False
End If
End If
End If
End Forall
If okSave Then
Call doc.Save(True, True)
End If
End If
End If
Code problem or type of pdf??
Any idea?
best regards
Heiner