A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Copy Outlook email body to Excel



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old July 11th 12, 03:44 PM
AlexCS AlexCS is offline
Junior Member
 
First recorded activity at Outlookbanter: Jul 2012
Posts: 1
Default Copy Outlook email body to Excel

Hi everyone,

I have been trying to write a macro in Excel to achieve the following:
- search for an item with a particular subject in the Outlook inbox (there will always be only one item to match the search criteria since the items are deleted after being processed)
- open that particular item and copy its body to a designated Excel spreadsheet
-delete the item

So far, the closest I have come to my objective is with the below code. My problem is that it ends up pasting the entire body of the email in one single cell in Excel (it would not accept pasting in a range) and there is no possibility for me to format the data afterwards.

Please help if you have a minute, I honestly don't know what else to try.

Many thanks,

Alex

Sub Outlook_Final()

Set olApp = CreateObject("Outlook.Application")

Dim olNs As Outlook.Namespace
Dim Fldr As Outlook.MAPIFolder

Set olApp = New Outlook.Application
Set olNs = olApp.GetNamespace("MAPI")
Set Fldr = olNs.GetDefaultFolder(olFolderInbox)

For Each Item In Fldr.Items
If InStr(Item.Subject, "MACRO VAX 48634 REPORT") 0 Then
Item.Display
vBody = Item.Body
ActiveWorkbook.Sheets("Sheet1").Range("A1").Value = vBody
Item.Delete
End If
Next Item

End Sub
Ads
 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Export body of email to Excel Jim[_15_] Outlook - General Queries 2 April 14th 09 05:14 PM
Copy a range from Excel to Oulook MailItem's body as Bitmap WhytheQ Outlook and VBA 8 November 2nd 07 01:33 PM
Copy contents of Excel range name to Email Subject line [email protected] Outlook and VBA 3 June 21st 07 07:14 AM
Need help with 2 HTML files in the body of an email using excel co Trefor Outlook and VBA 7 January 11th 07 05:28 AM
Paste an Excel Chart in an Outlook Body [email protected] Outlook and VBA 1 September 27th 06 06:39 AM


All times are GMT +1. The time now is 05:02 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.