Q:

Move Lotus Notes Email to a Different Folder Python

After extracting some of the email's data, I would like to move the email to a specified folder with python.  I've searched and haven't seemed to find what I need. 
Has anyone done this before? 
Per a comment, I've added my current logic in hopes that it will clarify my problem.  I loop through my folder, extract the details.  After doing that, I want to move the email to a different folder. 
import win32com.client
import getpass
import re

'''
Loops through Lotus Notes folder to view messages
'''
def docGenerator(folderName):
    # Get credentials
    mailServer = 'server' 
    mailPath = 'PubDir\inbox.nsf'

    # Password
    pw = getpass.getpass('Enter password: ')

    # Connect
    session = win32com.client. Dispatch('Lotus. NotesSession')

    # Initializing the session and database
    session. Initialize(pw)
    db = session. GetDatabase(mailServer, mailPath)

    # Get folder
    folder = db. GetView(folderName)
    if not folder:
        raise Exception('Folder "%s" not found' % folderName)

    # Get the first document
    doc = folder. GetFirstDocument()

    # If the document exists,
    while doc:
        # Yield it
        yield doc

        # Get the next document
        doc = folder. GetNextDocument(doc)

# Loop through emails
for doc in docGenerator('Folder\Here'):

    # setting variables
    subject = doc. GetItemValue('Subject')[0].strip()
    invoice = re.findall(r'\d+',subject)[0]
    body = doc. GetItemValue('Body')[0].strip()

    # Move email after extracting above data
    # ??? 

A:

As you will move the document before getting the next one, I'd recommend to replace your loop with
doc = folder. GetFirstDocument()
while doc:
    docN = folder. GetNextDocument(doc)
    yield doc
    doc = docN

And then to move the message to the proper folder you need
doc. PutInFolder(r"Destination\Folder")
doc. RemoveFromFolder(r"Origin\Folder")

Of course, take care of escaping your backslashes or using raw strings literals to pass correctly the view name. 
doc. PutInFolder creates the folder if it doesn't exist.  In that case the user needs to have permissions to create public folders, otherwise the created folder will be private. ( If the folder already exists, of course, this is not a problem.)