Extracting certain parts of an email using Python (Regex)
Question: I am trying to create a program that will import messages from a particular
folder in Outlook and then extract certain parts in the email.

The emails are of the form: Dear Mr.X,

{Lines of Text} See below.

Client: Company X

Fund: ABCD

Size:

Thanks, Sam

The code i have so far is:

    
    
    import win32com.client
    outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
    inbox = outlook.GetDefaultFolder(4)
    messages = inbox.Items
    message = messages.GetLast()
    body_content = message.body
    

Can someone help me with the code using regex to extract all pieces of
information in the email that follows the ":" such as Client:CompanyX, etc.?


Answer: You don't need `regex` just
[split()](https://docs.python.org/2/library/stdtypes.html#str.split) the text
on the `:` and get the last element:

    
    
    In [5]: s = "Client: Company X"
    
    In [6]: print s.split(":")[-1]
    Company X
    In [7]: s = "Fund: ABCD"
    
    In [8]: print s.split(":")[-1]
     ABCD
    

