Skip to main content
 
developerWorks
AIX and UNIX
Information Mgmt
Lotus
New to Lotus
Products
How to buy
Downloads
Live demos
Technical library
Training
Support
Forums & community
Events
Rational
Tivoli
WebSphere
Java™ technology
Linux
Open source
SOA and Web services
Web development
XML
My developerWorks
About dW
Submit content
Feedback



developerWorks  >  Lotus  >  Forums & community  >  Notes/Domino 4 and 5 Forum

Notes/Domino 4 and 5 Forum

developerWorks

  


Problem with forwarding email without attachments in LotusScript...
Alex Grant 15.Apr.03 07:46 AM a Web browser
Domino Designer -- LotusScript Release 4 Windows 2000

Hi All,

For the last few days I have been trying to write some code which will strip out any attachments from an email when I'm forwarding the mail.

My code is in an agent which acts on selected documents and is triggered from the action button on the Inbox.

The code I have written checks a document in my inbox and if it is of form type 'memo' or 'document' and has attachments then the 'AlternativeForward' sub is called otherwise the 'NormalForward' sub is called.

The 'NormalForward' sub works no problems but when the 'AlternativeForward' sub is called to remove attachments it creates the new memo to be forwarded but still has the attachment visible and gives two error messages in a row 'Notes Item not found' and then 'User defined error'. The code errors out at the line 'Call cUidoc.Forward' at the bottom of the 'AlternativeForward' sub.

Form trying to debug the code it seems to be the section below in the 'AlternativeForward' sub which is causing the problem. If I remove it the code, although it doesn't remove the attachments, it executes without errors. This is as far as I can get, I just can't seem to solve this...

If NoteVersion% = 1 Then

Forall i In cThisdoc.Items

If (i.Type = 1084) Then
Call cThisdoc.RemoveItem( i.Name )
cThisdoc.AttachmentsDeletedMsg = "*******Attachment(s) have been removed*******"
End If

End Forall
Else
If NoteVersion% = 2 Then

If cThisdoc.HasEmbedded = True Then

Forall x In item.embeddedObjects

If x.type=1454 Then
x.remove
cThisdoc.AttachmentsDeletedMsg = "*******Attachment(s) have been removed*******"
End If

End Forall

End If

End If
End If


If anyone can show me where I've gone wrong I'd be very grateful.

Thanks in advance,

A.

P.S.
Here is my code...

(Declarations)
Dim cSession As NotesSession
Dim cThisdb As NotesDatabase
Dim cThisdc As NotesDocumentCollection
Dim cThisdoc As NotesDocument

Dim cWorkspace As NotesUIWorkspace


Sub Initialize
Dim NoteVersion As Integer

Set cSession = New NotesSession
Set cWorkspace = New NotesUIWorkspace
Set cThisdb = cSession.currentDatabase
Set cThisdc = cThisdb.UnprocessedDocuments
Set cThisdoc = cThisdc.GetFirstDocument

If (cThisdoc Is Nothing) Then
Msgbox "No document is selected; please select a document to forward.", 0,"Lotus Notes"
Exit Sub
End If

If Not (cThisdoc.Form(0) = "Memo" Or cThisdoc.Form(0) = "Document") Then
Call NormalForward
Else
NoteVersion% = checkattach()
If NoteVersion% = 0 Then
Call NormalForward
Else
Call AlternativeForward(NoteVersion%)
End If
End If
End Sub



Private Sub NormalForward
Dim cUidoc As NotesUIDocument
Dim tempdoc As NotesDocument
Dim item, rtitem As NotesRichTextItem
Dim success As Variant

Set tempdoc = New NotesDocument(cThisdb)

If cThisdoc.HasItem("$KeepPrivate") And cThisdoc.~$KeepPrivate(0) = "1" Then
Msgbox " The sender has prevented you from forwarding or printing this document." , 0, "Feature Unavailable"
Exit Sub
End If

tempdoc.Form = "TempForwardForm"

If cThisdoc.HasItem("Subject") Then
tempdoc.Subject = cThisdoc.Subject(0)
End If

Set rtitem = New NotesRichTextItem( tempdoc, "Body" )

While Not(cThisdoc Is Nothing)
If cThisdoc.HasItem("$KeepPrivate") And cThisdoc.~$KeepPrivate(0) = "1" Then
Set cThisdoc = cThisdc.GetNextDocument(cThisdoc)
Else
Set item=cThisdoc.getFirstItem("body")
If cThisdoc.HasItem("$REF") Then
Call cThisdoc.RemoveItem("$REF")
End If

If cThisdoc.Form(0) = "Appointment" Then
cThisdoc.Form = "Temp Calendar Entry"
Else
If cThisdoc.Form(0) = "Notice" Then
cThisdoc.Form = "Temp Notice"
End If
End If

success = cThisdoc.RenderToRTItem( rtitem )

Set cThisdoc = cThisdc.GetNextDocument(cThisdoc)
End If
Wend

Call tempdoc.Save( True, False)
Set cUidoc = cWorkspace.EditDocument(True, tempdoc)
Call cUidoc.Forward
Call tempdoc.remove(True)
Call cUidoc.Close
End Sub



Private Sub AlternativeForward(NoteVersion As Integer)
Dim cUidoc As NotesUIDocument
Dim tempdoc As NotesDocument
Dim item, rtitem As NotesRichTextItem
Dim success As Variant

Set tempdoc = New NotesDocument(cThisdb)

If cThisdoc.HasItem("$KeepPrivate") And cThisdoc.~$KeepPrivate(0) = "1" Then
Msgbox " The sender has prevented you from forwarding or printing this document." , 0, "Feature Unavailable"
Exit Sub
End If

tempdoc.Form = "TempForwardForm"

If cThisdoc.HasItem("Subject") Then
tempdoc.Subject = cThisdoc.Subject(0)
End If

Set rtitem = New NotesRichTextItem( tempdoc, "Body" )

While Not(cThisdoc Is Nothing)
If cThisdoc.HasItem("$KeepPrivate") And cThisdoc.~$KeepPrivate(0) = "1" Then
Set cThisdoc = cThisdc.GetNextDocument(cThisdoc)
Else
Set item=cThisdoc.getFirstItem("body")

If NoteVersion% = 1 Then

Forall i In cThisdoc.Items

If (i.Type = 1084) Then
Call cThisdoc.RemoveItem( i.Name )
cThisdoc.AttachmentsDeletedMsg = "*******Attachment(s) have been removed*******"
End If

End Forall
Else
If NoteVersion% = 2 Then

If cThisdoc.HasEmbedded = True Then

Forall x In item.embeddedObjects

If x.type=1454 Then
x.remove
cThisdoc.AttachmentsDeletedMsg = "*******Attachment(s) have been removed*******"
End If

End Forall

End If

End If
End If

If cThisdoc.HasItem("$REF") Then
Call cThisdoc.RemoveItem("$REF")
End If

If cThisdoc.Form(0) = "Appointment" Then
cThisdoc.Form = "Temp Calendar Entry"
Else
If cThisdoc.Form(0) = "Notice" Then
cThisdoc.Form = "Temp Notice"
End If
End If

success = cThisdoc.RenderToRTItem( rtitem )

Set cThisdoc = cThisdc.GetNextDocument(cThisdoc)
End If
Wend

Call tempdoc.Save( True, False)
Set cUidoc = cWorkspace.EditDocument(True,tempdoc)
Call cUidoc.Forward
Call tempdoc.remove(True)
End Sub



Function CheckAttach() As Integer
If cThisdoc.HasItem( "EmbeddedObject" ) Then
CheckAttach = 2
Else
If cThisdoc.HasItem( "$File" ) Then
CheckAttach = 1
Else
CheckAttach = 0
End If
End If
End Function






  Document options
Print this pagePrint this page

 Search this forum

  Forum views and search
Date (threaded)
Date (flat)
With excerpt
Author
Category
Platform
Release
Advanced search


 RSS feedsRSS
All forum posts RSS
All main topics RSS
More Lotus RSS feeds

 Resources
Forum use and etiquette
Native Notes Access
Web site Feedback

  Lotus Support
Lotus Support
Product support pages index
Search knowledge base (Technotes)
Search support downloads
Lotus Support RSS

 Wikis
IBM Composite Applications
IBM Mashup Center
IBM Connections
IBM Docs
IBM Forms
IBM Mobile Connect
IBM Sametime
IBM SmartCloud for Social Business
IBM Web Experience Factory
Lotus Domino
Lotus Domino Designer
Lotus Expeditor
Lotus Foundations
Lotus iNotes
Lotus Instructor Community Courseware
Lotus Notes
Lotus Notes & Domino Application Development
Lotus Notes Traveler
Lotus Protector
Lotus Quickr
Lotus Symphony
IBM Web Content Manager
WebSphere Portal

 Lotus Forums
Notes/Domino 9.0
Notes/Domino 8.5 + Traveler
Notes/Domino XPages development forum
Notes/Domino 8
Notes/Domino 6 and 7
Notes/Domino 4 and 5
IBM Connections
IBM Forms
IBM Mobile Connect
IBM Sametime
IBM SmartCloud Notes
IBM SmartCloud Meetings
IBM Web Content Manager
Lotus Domino Document Manager
Lotus e-learning
Lotus Enterprise Integration
Lotus Expeditor
Lotus Protector
Lotus Quickr
Lotus SmartSuite
Lotus Symphony
Lotus Symphony Developer Toolkit Support
Lotus Workflow