Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How do I parse the body of an email, and export the fields into Excel using VBA

Posted on 2004-03-24
5
Medium Priority
?
189 Views
Last Modified: 2010-08-05
I have an email body that is constructed as follows:

NAME
ORG
DATE
TIME
LOCATION

Each line item is to be a separate field in Excel.  How do I access each line uniquely?
Thanks,
Russ
0
Comment
Question by:RUSS_EMI
  • 2
5 Comments
 
LVL 1

Expert Comment

by:millicent_lam
ID: 10678037
You can only export data from an email to Excel if you are using a custom form. Every item that you open in Outlook uses a form to display information. E.g. email messages use the Message form, a new contact is entered via the Contact form.

In your case, you will need to customise the Message form, publish it in a Forms Library, and only then you can export data into Excel using VBScript or VBA, depending on what version of Outlook you are using.

www.slipstick.com is a good place to start with.
0
 

Author Comment

by:RUSS_EMI
ID: 10684445
The code stops after Set ex = CreateObject("Excel.Applicaton").
Here is my complete code, running within the Rules Wizard as a script in Outlook.

Sub TestMessageRule(Item As Outlook.MailItem)
Dim lines As Variant
Dim sheet
Dim ex
Dim x As Long

lines = Split(Item.Body, VbCr)
Set ex = CreateObject("Excel.Applicaton")
Set objWB = ex.Workbooks.Open("c:\tryme.xls")
Set sheet = objWB.Sheets.Item(1)

For x = 0 To UBound(lines)
              sheet.cells(1, x).Value = lines(x)
Next x

objWB.Save
ex.Quit
Set ex = Nothing
End Sub

Thanks,
Russ
0
 

Author Comment

by:RUSS_EMI
ID: 10685039
I found the problem.  No longer need assistance with this exact question.  Need to close out and refund points.  Need help with appending data to Excel, rather than creating a new one each time.
0
 
LVL 1

Accepted Solution

by:
GhostMod earned 0 total points
ID: 11019371
PAQed, with points refunded (500)

GhostMod
Community Support Moderator
0

Featured Post

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Changing a few Outlook Options can help keep you organized!
This article describes how to import Lotus Notes Contacts into Outlook 2016, 2013, 2010 and 2007 etc. with a few manual steps. You can easily export and migrate Lotus Notes contacts into Microsoft Outlook without having to use any third party tools.
CodeTwo Sync for iCloud (http://www.codetwo.com/sync-for-icloud?sts=6554) automatically synchronizes your Outlook 2016, 2013, 2010 or 2007 folders with iCloud folders available via iCloud Control Panel. This lets you automatically sync them with…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

972 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