import email from Outlook
Dick,
In XP and with the body of the email in cell "AI" I tried the
"emaillines" sub but ran into "Run-time error '-2147352567
(80020009)':
Array index out of bounds."
How to fix please.
TIA
Ron
On Wed, 12 Nov 2003 08:13:28 -0600, "Dick Kusleika"
wrote:
charelke
The Body property is just a string, so you can manipulate it like any other
stirng. Here's an example
Sub emaillines()
Dim ol As Outlook.Application
Dim ns As Outlook.NameSpace
Dim fldr As Outlook.MAPIFolder
Dim mi As Outlook.MailItem
Dim stBody As String
Dim LineBreak As Long
Dim i As Long
Set ol = New Outlook.Application
Set ns = ol.GetNamespace("MAPI")
Set fldr = ns.GetDefaultFolder(olFolderInbox)
Set mi = fldr.Items(78)
stBody = mi.Body
LineBreak = 1
i = 1
Do
ActiveSheet.Cells(i, 1).Value = _
Mid(stBody, LineBreak, InStr(LineBreak, stBody, Chr(10)) -
LineBreak)
LineBreak = InStr(LineBreak + 1, stBody, Chr(10)) + 1
i = i + 1
Loop Until LineBreak = 0 Or LineBreak Len(stBody)
End Sub
|