T
tysone
I posted this in a similar group, but that group looks all but dead. Not that this one is pumping full of life, but I'm giving it a go. So please forgive me for the double-esk post
======================
So I think I'm 90% of where I want to be, and I'm hoping someone can help me.
The code below works great, but it has two problems for what I need. I do not want it pulled from "CurrentFolder," I want it to always pull from the inbox. And the second part of my problem its not my main inbox, it's on a second account I have linked in my outlook (for example sake call it "(e-mail address removed)").
Help would be greatly appreciated,
Sub Extract()
On Error Resume Next
Set myOlApp = Outlook.Application
Set myNameSpace = myOlApp.GetNamespace("mapi")
'==this is my issue, I do not want it coming from currentfolder==
Set myfolder = myOlApp.ActiveExplorer.CurrentFolder
Set xlobj = CreateObject("excel.application.14")
xlobj.Visible = True
xlobj.workbooks.Add
xlobj.Range("A" & 1).Value = "Recieved time"
xlobj.Range("B" & 1).Value = "Sender"
xlobj.Range("C" & 1).Value = "Subject"
xlobj.Range("D" & 1).Value = "Size"
For i = 1 To myfolder.Items.Count
Set myitem = myfolder.Items(i)
msgtext = myitem.Body
xlobj.Range("A" & i + 1).Value = myitem.ReceivedTime
xlobj.Range("B" & i + 1).Value = myitem.Sender
xlobj.Range("C" & i + 1).Value = myitem.Subject
xlobj.Range("D" & i + 1).Value = myitem.Size
Next
End Sub
======================
So I think I'm 90% of where I want to be, and I'm hoping someone can help me.
The code below works great, but it has two problems for what I need. I do not want it pulled from "CurrentFolder," I want it to always pull from the inbox. And the second part of my problem its not my main inbox, it's on a second account I have linked in my outlook (for example sake call it "(e-mail address removed)").
Help would be greatly appreciated,
Sub Extract()
On Error Resume Next
Set myOlApp = Outlook.Application
Set myNameSpace = myOlApp.GetNamespace("mapi")
'==this is my issue, I do not want it coming from currentfolder==
Set myfolder = myOlApp.ActiveExplorer.CurrentFolder
Set xlobj = CreateObject("excel.application.14")
xlobj.Visible = True
xlobj.workbooks.Add
xlobj.Range("A" & 1).Value = "Recieved time"
xlobj.Range("B" & 1).Value = "Sender"
xlobj.Range("C" & 1).Value = "Subject"
xlobj.Range("D" & 1).Value = "Size"
For i = 1 To myfolder.Items.Count
Set myitem = myfolder.Items(i)
msgtext = myitem.Body
xlobj.Range("A" & i + 1).Value = myitem.ReceivedTime
xlobj.Range("B" & i + 1).Value = myitem.Sender
xlobj.Range("C" & i + 1).Value = myitem.Subject
xlobj.Range("D" & i + 1).Value = myitem.Size
Next
End Sub