Move Lotus Notes mail to a folder in Lotus Notes through VBA
:hi: Hello Everyone
I am a new member to this forum.
I searched for my query in this forum but not able to find the answer. Please forgive me if these kind of questions were already answered in past.
I got a task where I have to to create VBA which will detach attachments from LN inbox mails, delete the attachment, move those mails to a Lotus Notes folder and finally send automatic reply mail to sender.
I am able to detach attachments from mail but not able to move mail documents from Inbox to "Cleared" folder in LN.
This is what I have used :
..................
If (attch.Type = EMBED_ATTACHMENT) Then
attch.ExtractFile sPathToSave & attch.Name 'save attachment to directory
attch.remove 'delete attachment from mail
End If
doc.PutInFolder "Cleared", True 'copy mail to Cleared Folder in LN
doc.Removefromfolder "($Inbox)", True 'delete mail from inbox
........................
This code makes copy of first mail in 'Processed' folder of LN but never delete mail from Inbox. In fact, it create two copies which are seemed to be linked. That means if I delete mails from inbox (after code run) mails also get deleted from 'Processed' folder. Moreover, due to this issue the loop is running on the first mail only.
Can someone please help me and guide me on this.
Thanks.
Answer to why item gets deleted from both folders...
(I know this issue was answered a year back, but this is background info on Lotus Notes behaviour)
I found this thread while looking for info on Lotus Notes' object model for a bit of access from VBA and scripting tools. I've used Notes for ages
The way Notes uses folders means that a document (email etc) can be in more than one folder. It's not like a disk file being in only one folder by definition, it's more like tagging a message in a blog or on twitter, where several tags can be relevant. Think cross-references and you start to get the idea.
So simply putting a document into a folder doesn't move it out of where it is. And the Inbox is a folder in Notes's terms. Equally, deleting a document that's in the Inbox does what it says on the tin: it deletes the document from the database, so it disappears from both Inbox and wherever else it is (""Cleared" in this example).
What you have to do is put the document into your target folder and then use "remove from folder" to stop it appearing in the Inbox. In the Notes user interface, there is a "move to folder" option which does indeed do both operations in one click - but I don't know whether that is available from VBA. I suspect it isn't in order to give programmer control and because it would only be one extra statement to code.
Hope that's interesting & useful. Now back to my problem...