CDO, MAPI, and vbscript OH MY - Retreiving Exchange email

Posted on 2004-11-17
Last Modified: 2008-01-09
We do our own spam filtering and seeing how much time is being spent slowing spam I wanted to write a script that reads emails in a folder of a user's mailbox and find similarities.  There is one issue that I can't seem to figure out.

Here is some of what I used to get where I am at:

 Set objSession = CreateObject("MAPI.Session")       'Creates the MAPI session
 objSession.Logon "outlook"                  'Logs on using the 'outlook' profile
 set objMailbox = objSession.GetDefaultFolder(1)      'get the default Inbox
 set objFolder = objMailbox.folders.Item("Spam")     'get 'Spam' folder within the Inbox
 Set objMsgColl = objFolder.Messages   'gets collection of all emails in the folder objFolder
 set firstemail = objMsgColl.GetFirst()            'retreives me the first email - just to test

Now I can display what I thought was the body of the email like this:

 wscript.echo firstemail.text

However I noticed that all the text was not there.  I'm assuming this may be a plain text version or some kind of specially decoded version of the body since the missing parts were html tags.

Now I have tried desparately to figure out how to retreive the full untouched body of the message (or at least all parts of a multipart message) but can't figure out how to make it work on vbscript.  Can anyone here throw me a bone?
Question by:joshuad156
    LVL 19

    Accepted Solution


    Author Comment

    Thank you so very much.  I have had a very difficult time finding the proper method to access this information and you have given me exactly what I asked for.
    LVL 19

    Expert Comment

    Glad I could help :)

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Suggested Solutions

    Title # Comments Views Activity
    Doc'in system (example?) BA 7 63
    Problem to setup 18 65
    add text to end of existing text in file 16 54
    mergeTwo  challenge 13 53
    This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
    Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
    An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
    In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now